Powershell Tip #111: Get names and values of Enum

By | August 16, 2016

Tip: You can get the names / values of an Enumeration object by using the GetEnumNames or GetEnumValues static method.

You can identify enumeration by the Enum keyword.

powershell-enumerations-object-fileattributes

Here is an example with thefile attributes from System.IO namespace.

FileAttributes Enumeration
https://msdn.microsoft.com/en-us/library/system.io.fileattributes(v=vs.110).aspx

Note: For versions prior to PowerShell v3 :

powershell-enum-getvalues-getnames-object-fileattributes

To see the list of enumerations from System.IO Namespace :

System.IO Namespace
https://msdn.microsoft.com/en-us/library/system.io(v=vs.110).aspx


previous-buttonnext-button

One thought on “Powershell Tip #111: Get names and values of Enum

  1. Pingback: Powershell Tip #112: Get int values from Enum | Powershell Guru

Leave a Reply

Your email address will not be published. Required fields are marked *