Dear Developers,
I have noticed a certain behaviour of New-AlarmAction:
$EmailTo = "alerts@domain.local"
New-AlarmAction -Email -To $EmailTo
New-AlarmAction : Cannot bind parameter 'To' to the target. Exception setting "To": "Invalid email address: alerts@domain.local"
It does not seem to validate email addresses that end with ".local" instead of standard: ".com", etc.
Do you think it would be possible to introduce a more relaxed email validation in future versions of PowerCli ?
I support your request, the cmdlet shouldn't be more strict then the vSphere client.
Until this is changed you could use the following bypass.
$alarm = Get-AlarmDefinition -Name TestAlarm $spec = $alarm.ExtensionData.Info
$spec.Action.Action | where {$_.Action -is [VMware.Vim.SendEmailAction]} | %{ $_.Action.ToList = "lucd@test.local"
} $alarm.ExtensionData.ReconfigureAlarm($spec)
You can of course make the email action logic more strict. For example only replace the To address when it has a specific value.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks LucD, your script works like a charm!
Funny enough, i was just looking at your other script located at http://www.lucd.info/2009/11/15/scripts-for-yellow-bricks-advise-thin-provisioning-alarm-eagerzeroed..., trying to figure out how to do this
Thanks again!