Last active
October 10, 2015 11:19
-
-
Save deangrant/10198f223182db9b9abd to your computer and use it in GitHub Desktop.
Snippet for validating email address with custom error in Create-EmailHash function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CmdletBinding()] | |
Param ( | |
[Parameter(Mandatory=$True, ValueFromPipeline=$True, HelpMessage="Enter an email address to compute hash")] | |
[ValidateScript({If ($_ -match "\b[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4}\b") {$True} | |
Else {Throw "The email address $_ is not a valid email address format."}})] | |
[String[]]$Email | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment