Upon finishing to install the EmailVerify.NET snap-in, the Verify-EmailAddress cmdlet becomes available for you to use within a given Windows PowerShell session; this section contains some PowerShell scripts which shows how the provided verification cmdlet can be used in order to verify e-mail address from within PowerShell.
Example 1 - Verifying a single e-mail address from PowerShell
| Example 1 | Copy Code |
|---|---|
|
(Verify-EmailAddress johndoe@example.com).IsSuccess | |
This command syntactically validates the email address johndoe@example.com and returns a boolean value which tells if the address is valid or not.
Note that the default verification level is Syntax. To specify a different verification level user the -Level parameter.
Example 2 - Validating multiple e-mail address at once from PowerShell
| Example 2 | Copy Code |
|---|---|
|
'me@example.com', 'you@example.com' | ? { (Verify-EmailAddress $_ -Level MailBox).IsSuccess } | |
This command takes a couple of e-mail addresses from the pipeline and validates them up to the mailbox level, returning just the items which pass the verification.
Example 3 - Validates an e-mail address up to the catch-all level and display the eventual failure reason from PowerShell
| Example 3 | Copy Code |
|---|---|
|
$validationResult = (Verify-EmailAddress 'johndoe@example.com' CatchAll) if ($validationResult.IsSuccess -eq $false) { | |
This command validates the e-mail address johndoe@example.com up to the CatchAll level and, should it fails, it tells what is the cause of the failure.