Skip to content

Instantly share code, notes, and snippets.

@kpatnayakuni
Created January 21, 2020 12:16
Show Gist options
  • Select an option

  • Save kpatnayakuni/36dc7f96d2c99616ade9634a5755a94e to your computer and use it in GitHub Desktop.

Select an option

Save kpatnayakuni/36dc7f96d2c99616ade9634a5755a94e to your computer and use it in GitHub Desktop.
Demo Dynamic ValidateSet
class SupportedCountries : System.Management.Automation.IValidateSetValuesGenerator
{
[string[]] GetValidValues()
{
## Write your code here
$Countries = @('India', 'USA', 'UK', 'Canada', 'Australia')
return $Countries
}
}
Function Get-Country
{
[CmdLetBinding()]
param
(
[parameter(Mandatory = $true)]
[ValidateSet([SupportedCountries])]
[string] $CountryName
)
## Write your code here
Write-Host $CountryName
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment