- # Get-ForestModeEnumValues.ps1
- # Prints out the values of the ForestMode Enum
- # Thomas Lee - tfl@psp.co.uk
- # Enumerate System.DirectoryServices.ActiveDirectory.forestmode
- $enums=[enum]::GetValues([System.DirectoryServices.ActiveDirectory.ForestMode])
- # Display values
- "System.Net.DirectoryServices.ActiveDirectory.Forest mode enum has {0} possible values:" -f $enums.count
- $i=1
- $enums | %{"Value {0}: {1}" -f $i,$_.tostring();$i++}
- ""
- # Checking against an enum value
- $ToCheck = "Windows2008Forest"
- if ($ToCheck -eq [System.DirectoryServices.ActiveDirectory.ForestMode]::Windows2008Forest) {
- "`$ToCheck is Windows2008Forest"
- }
- else {
- "`$ToCheck is NOT Windows2008Forest"
- }
This script produces the following output:
PS C:\foo> .\Get-ForestModeEnumValues.ps1
System.Net.DirectoryServices.ActiveDirectory.Forest mode enum has 4 possible values:
Value 1: Windows2000Forest
Value 2: Windows2003InterimForest
Value 3: Windows2003Forest
Value 4: Windows2008Forest$ToCheck is Windows2008Forest
No comments:
Post a Comment