VMware Cloud Community
yunnerator
Contributor
Contributor

New-AlarmAction e-mail address validation

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 ?

0 Kudos
2 Replies
LucD
Leadership
Leadership

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

yunnerator
Contributor
Contributor

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 Smiley Happy

Thanks again!

0 Kudos