Skip to content

Handling enums as cmdlet parameters. #396

@DieWat

Description

@DieWat

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().
#>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions