Functional Levels and PowerShell

We were prepping a global enterprise to raise their forest and domain functional levels to Windows Server 2012 R2. We wanted to know that ALL the DCs were seeing/registering the new level. So in comes my favorite scripting tool – PowerShell. Here’s the code we ended up using:

$dcs = Get-ADDomainController -Filter *
#for each DC - query the ForestMode
$out = @{}
Foreach($dc in $dcs)
$forest = Get-ADForest -Server $dc
$domain = Get-ADDomain -Server $dc
$modes = $forest.ForestMode.ToString() + ", " + $domain.DomainMode.ToString()
$out | ogv

The output will return a grid with all the DCs in the domain with the current value of the forest and domain level:


Of course this is an output from the Newton lab, your output will have the DCs in your domain.

Want to learn more?


Written by:

Leave a comment