One-Liner: Specific GPO and DC Information from a Forest

Man, I love PowerShell one-liners. The efficiency, the elegance, the challenge!

Here's one to give me a list of the domain names in a forest, the number of group policies per domain and the number of domain controllers per domain.

 

(Get-ADForest).Domains | ForEach-Object {"Domain Name`: $_"; "Number of GPOs`: $((Get-GPO -All -Domain $_ ).count)"; "Number of DCs`: $((Get-ADDomainController -Filter * -Server $_).count)"; Write-Host}