Kae Travis

List AD Sites and Subnets using PowerShell

This is a simple script to list AD sites and subnets using PowerShell.

$sites = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().Sites           

foreach ($site in $sites) {   
    write-host "(site) $site"    
    foreach ($subnet in $site.Subnets) {
        write-host "....(subnet) $subnet"
        foreach ($server in $site.Servers) {
            write-host "........(server) $server"
        }
    }
}
List AD Sites and Subnets using PowerShell
List AD Sites and Subnets using PowerShell

Leave a Reply