DiD you know : You can find all values belonging to an ENUM in powershell

POSH TIP: List all values belonging to an ENUM in powershell

Enum is a value type available in .NET framework. Use GetNames static method of this class to list down all values belonging to and ENUM as shown below

[Enum]::GetNames([System.Management.Automation.ActionPreference])

In the above command System.Management.Automation.ActionPreference is the Enum whose values we are interested in..

The above code return a string array and it looks like below

    SilentlyContinue
    Stop
    Continue
    Inquire
    Ignore
    Suspend

The above code can be used with an .NET Enumeration type.

Another example are below..

[Enum]::GetNames([System.Windows.Forms.MessageBoxButtons])

    OK
    OKCancel
    AbortRetryIgnore
    YesNoCancel
    YesNo
    RetryCancel

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s