Thursday, January 13, 2011

Quick Active Directory Sites & Subnets Report

This is a quick report I wrote up to generate a list of sites & subnets within a Forest to compare against network topology. Pipe it out to a text file and mail it off to your networking team (which might be you!).
$forestInformation = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()
foreach($site in $forestInformation.Sites | Sort-Object -property Name) {
   Write-Output $site.Name
   Write-Output ("-" * ($site.Name).Length)
   foreach($subnet in $site.Subnets | Sort-Object) {
      Write-Output "`t$subnet"
   }
   Write-Output ""
}

No comments:

Post a Comment