Skip to main content
Blog

Functional Levels and PowerShell

by Dan Newton

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)
{
$dc.name
$forest = Get-ADForest -Server $dc
$domain = Get-ADDomain -Server $dc
$modes = $forest.ForestMode.ToString() + ", " + $domain.DomainMode.ToString()
$out.Add($dc,$modes)
}
$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:

functional_levels

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


Leave a comment