Musings on the splendour of PowerShell One-Liner: Specific GPO and DC Information from a Forest - PoSh Chap - Site Home - TechNet Blogs

PoSh Chap

Musings on the splendour of PowerShell

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

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

  • Comments 1
  • Likes

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


Comments
  • Thanks very interesting
    didnt know you can do that to that extend

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment