Thursday, August 30, 2007

Email address validation with PowerShell and Exchange 2007


This function verifies if a string is a qualified email address.

function Validate-EmailAddress{
    param([string]$email)
    [Microsoft.Exchange.Data.SmtpAddress]::IsValidSmtpAddress($email);
}


>> Validate-EmailAddress "Shay@homelab.loc"
True

>> Validate-EmailAddress "Shay.homelab.loc"
False

1 comment:

Joe Cruz said...

I was searching high and low for a way to do Email Address validation in PowerShell. You apparently have cornered the market on this particular script and wanted to let you know how much time you saved me! Thanks for the post. I'm going to link to your blog from mine.