Created
January 21, 2020 12:16
-
-
Save kpatnayakuni/36dc7f96d2c99616ade9634a5755a94e to your computer and use it in GitHub Desktop.
Demo Dynamic ValidateSet
This file contains hidden or 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
| 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