Skip to content

Instantly share code, notes, and snippets.

@RobBiddle
Created March 4, 2019 18:15
Show Gist options
  • Save RobBiddle/d88d7c760dd363715f3c1cc0f4caba97 to your computer and use it in GitHub Desktop.
Save RobBiddle/d88d7c760dd363715f3c1cc0f4caba97 to your computer and use it in GitHub Desktop.
PowerShell Parameter ValidatePattern (REGEX) validation check which will match either a valid GUID or a valid FQDN
[Parameter]
[ValidatePattern( '(?=^.{1,254}$)(^(?:(?!\d+\.|-)[a-zA-Z0-9_\-]{1,63}(?<!-)\.?)+(?:[a-zA-Z]{2,})$)|(\{|\()?[A-Za-z0-9]{4}([A-Za-z0-9]{4}\-?){4}[A-Za-z0-9]{12}(\}|\()?' )]
[System.String]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment