PowerShell - Get Subnet to Site Details
- Jon Boyette
- Jan 11, 2022
- 1 min read
Copy and paste or save as a named.ps1, this will output ALL subnets that are hosted per site on the Domain and output to c:\temp\Sites.csv
[cmdletbinding()]
param()
$Sites = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().Sites
$obj = @()
foreach ($Site in $Sites) {
foreach($sub in $site.subnets){
$obj += New-Object -Type PSObject -Property (
@{
"SiteName" = $site.Name
"SubNet" = $sub.name
}
)}
}
$obj | Export-Csv 'c:\temp\sites.csv' –NoType
Comments