# enum-AuthenticationTypes.ps1
# Enum sample using PowerShell
# Thomas Lee - tfl@psp.co.uk
# Get enums
$enums=[enum]::GetValues([System.DirectoryServices.AuthenticationTypes])
# Display values
"System.DirectoryServices.AuthenticationTypes enum has {0} possible values:" -f $enums.count
$i=0
$enums | %{"Value {0}: {1}" -f $i,$_.tostring();$i++}
""
# Checking against an enum value
$ToCheck = "Secure"
if ($ToCheck -eq [System.DirectoryServices.AuthenticationTypes]::Secure)
{"`$ToCheck is Secure"}
else
{"`$ToCheck is NOT Secure"}
This script produces the following output:
PS C:\Documents and Settings\LeeT>
D:\foo\enum-AuthenticationTypes.ps1
System.DirectoryServices.AuthenticationTypes enum has 11 possible values:
Value 0: None
Value 1: Secure
Value 2: SecureSocketsLayer
Value 3: SecureSocketsLayer
Value 4: ReadonlyServer
Value 5: Anonymous
Value 6: FastBind
Value 7: Signing
Value 8: Sealing
Value 9: Delegation
Value 10: ServerBind
$ToCheck is Secure