Getting all domain controllers in a forest


Using something like Get-ADDomainController -Forest would be something too easy for module designers at Microsoft. Or does Microsoft no longer have multi-domain forests in its internal IT?

Never mind, here is a nice snippet to retrieve that you may want to adapt to the fields you need to retrieve

<pre class="lang:default decode:true " title="Retrieve all domain controllers from a forest">(Get-ADForest).Domains | % { Get-ADDomainController -Discover -DomainName  $_ } | % { Get-ADDomainController -server $_.Name -filter * } | Select Name, Domain, Forest, IPv4Address, Site | ft