Skip to content

Instantly share code, notes, and snippets.

@RamblingCookieMonster
Last active August 29, 2015 14:18
Show Gist options
  • Save RamblingCookieMonster/3e01f840e4160136523d to your computer and use it in GitHub Desktop.
Save RamblingCookieMonster/3e01f840e4160136523d to your computer and use it in GitHub Desktop.
Get-EnumValues.ps1
function Get-EnumValues {
<#
.SYNOPSIS
Return list of names and values for an enumeration object
.DESCRIPTION
Return list of names and values for an enumeration object
.PARAMETER Type
Pass in an actual type, or a string for the type name.
.EXAMPLE
Get-EnumValues system.dayofweek
.EXAMPLE
[System.DayOfWeek] | Get-EnumValues
.FUNCTIONALITY
General Command
#>
[cmdletbinding()]
param(
[parameter( Mandatory = $True,
ValueFromPipeline = $True,
ValueFromPipelineByPropertyName = $True)]
[Alias("FullName")]
$Type
)
Process
{
[enum]::getvalues($type) |
Select @{name="Type"; expression={$Type.ToString()}},
@{name="Name"; expression={$_.ToString()}},
@{name="Value"; expression={$_.value__}}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment