Skip to content

Instantly share code, notes, and snippets.

@thedavecarroll
Created May 18, 2020 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thedavecarroll/18ca62625df31fe82ba431b80f6ba2f5 to your computer and use it in GitHub Desktop.
Save thedavecarroll/18ca62625df31fe82ba431b80f6ba2f5 to your computer and use it in GitHub Desktop.
Validate Two Letter Region Names with PowerShell
$TwoLetterISORegionNames = Get-Culture -ListAvailable |
Foreach-Object {
try { [System.Globalization.RegionInfo]::new($_.Name) }
catch {}
} |
Select-Object -ExpandProperty TwoLetterISORegionName | Sort-Object -Unique
'US','CA','UK' | % { $_ -in $TwoLetterISORegionNames ? '{0} is valid' -f $_ : '{0} is not valid' -f $_ }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment