
Get the Active Directory functional levels/FSMO roles forest wide
Description
With the following script, it is possible in the same array to get useful Active Directory informations such as:
- domain names (DNS fqdn)
- domain functional level
- forest functional level
- fsmo roles
The powershell cmdlets used for this script are the get-adforest and get-addomain. The documentation for these cmdlets can be found here and here.
After that I use the select-object cmdlet (alias: select) to build my array.
The script
1 2 3 4 5 6 7 8 9 10 |
import-module act* $array=@() $ForestInfo = get-adforest $ForestADLevel = $ForestInfo.ForestMode $domains = $ForestInfo.Domains $domains | % { $array += get-addomain $_ | select @{n='DomainName';e={$_.DNSRoot}}, ` #Domain name DomainMode, @{n='ForestMode';e={$ForestADLevel}}, ` #Domain/Forest AD functional level PDCEmulator,InfrastructureMaster,RIDMaster,@{n='SchemaMaster';e={$ForestInfo.SchemaMaster}},@{n='DomainNamingMaster';e={$ForestInfo.DomainNamingMaster}} #FSMO role holders } |
The script has been tested successfully on a server running on Windows Server 2012R2