Add optional values to parameter in advanced functions

Hi Everyone,

I am trying to create a parameter that auto populates values, where user can accept one value from few optional values. While selecting parameter It should automatically show valid options like the way error actions is showing. I am confused about what needs to be done extra to parameter? Below is an example of what I am trying to achieve.

 Param(
        [Parameter(Mandatory=$false)]
        [string[]]$Status
        #Enabled,Disabled or NotValid needs to be shown with status parameter
        ) 

Hello,

You can read about the topic here

about Functions Advanced Parameters - PowerShell | Microsoft Docs.

I believe you are after “ValidateSet”

2 Likes