| external help file | PSScriptTools-help.xml |
|---|---|
| Module Name | PSScriptTools |
| online version | https://jdhitsolutions.com/yourls/a654eb |
| schema | 2.0.0 |
Test if a .NET class is an enum.
Test-IsEnum [-EnumType] <Type> [<CommonParameters>]This is a simple command to test if a .NET class is an enum.
PS C:\> Test-IsEnum DateTime
FalsePS C:\> if (Test-IsEnum ConsoleColor) { Show-Enum ConsoleColor}
Typename: System.ConsoleColor
Name Value
---- -----
Black 0
DarkBlue 1
DarkGreen 2
DarkCyan 3
DarkRed 4
DarkMagenta 5
DarkYellow 6
Gray 7
DarkGray 8
Blue 9
Green 10
Cyan 11
Red 12
Magenta 13
Yellow 14
White 15Because the command writes a boolean result, it is easy to use in an If statement.
Specify an enum type name like ConsoleColor
Type: Type
Parameter Sets: (All)
Aliases: Class, PropertyType
Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: FalseThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Learn more about PowerShell: http://jdhitsolutions.com/yourls/newsletter