PowerShell-RFC icon indicating copy to clipboard operation
PowerShell-RFC copied to clipboard

Handling enums as cmdlet parameters.

Open DieWat opened this issue 5 months ago • 0 comments

Summary of the new feature / enhancement

Changing the handling of enums as cmdlet parameters uses to display the possible values the values of the enum and the get the name for the value. Therefore xou get the same text if more than one name has the same value (see example below).

Proposed technical implementation details (optional)

<# Display option when using an enum as a parameter of an CmdLet. #>

Enum TestAction { Ignore = 0 Skip = 0 Replace = 1 New = 1 Remove = 2 Detete = 2

} # Enum TestAction

Function Test-Enum { param ( [Parameter( Mandatory )] [TestAction] $Action ) <#Do something#>

} # Function Test-Enum

<# If you enter on a prompt Test-Enum -Action and try to select an action you get the following sequence: Ignore Ignore Replace Replace Remove Remove Ignore It would be nice to get the alias names as well. Use [enum]::GetNames() instead [enum]::GetValues(). #>

DieWat avatar Jul 28 '25 16:07 DieWat