list domain controller site information with powershell

just a small follow up to a post i did about listing domain controllers with powershell.

 

to start, let’s grab the forest.

$myForest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()

 

just for fun, we’ll look at the domains of the forest.

$myforest.Domains

 

let’s look at all the available sites of the forest.

$myforest.Sites

 

this will output the domain controllers and the sites they belong to.  this is akin to using nltest /dclist:mydomain.

$myforest.Sites | % { $_.Servers }

 

might as well know the subnets of those sites, right?

$myforest.Sites | % { $_.Subnets }

Comments