August 27th, 2015

PowerTip: Find Numeric Value of Enum in PowerShell

Doctor Scripto
Scripter

Summary: Learn how to easily find the numeric value of an enum in Windows PowerShell.

Hey, Scripting Guy! Question How can I use Windows PowerShell to easily find the numeric value of an enumeration?

Hey, Scripting Guy! Answer Use square brackets to call the enum, call the enumeration property as a static property, and reference3
           the value__ property. Here is an example using the [fruit] enum created in yesterday’s post, 
           New PowerShell 5 Feature: Enumerations:

[fruit]::apple.value__

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.