Getting all domain controllers and their site names in the forest

The function discussed in this section is a simple wrapper on top of the Get-ADDomainController cmdlet to query all the domain controllers in forest and display frequently referred-to details, such as DC name, domain name, site name—whether these names are global catalog servers or not—and reachability of the domain controller:

Function Get-DCDetails { [CmdletBinding()] Param( ) $Domains = (Get-ADForest).Domains $DCs = $Domains | % { Get-ADDomainController -Filter * -Server $_ } foreach($DC in $DCs) { $OutputObj = New-Object -TypeName PSObject -Property @{ DCName = $User.Name; DCDomain = $null; IsGC = $null; SiteName = $Null; IsOnline = $null } if(Test-Connection -Computer $DC -Count ...

Get Active Directory with PowerShell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.