Below Powershell command will help you to get the Site name and associated Subnets for that particular sites in Active Directory.
$sites = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().Sites
$sitesubnets = @()
foreach ($site in $sites)
{
foreach ($subnet in $site.subnets){
$temp = New-Object PSCustomObject -Property @{
'Site' = $site.Name
'Subnet' = $subnet; }
$sitesubnets += $temp
}
}
$sitesubnets | Export-CSV subnet.csv
$sites = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().Sites
$sitesubnets = @()
foreach ($site in $sites)
{
foreach ($subnet in $site.subnets){
$temp = New-Object PSCustomObject -Property @{
'Site' = $site.Name
'Subnet' = $subnet; }
$sitesubnets += $temp
}
}
$sitesubnets | Export-CSV subnet.csv
No comments:
Post a Comment