Posted On May 30, 2019

PowerShell: Script to Obtain List of Sites and Associated Domain Controllers

kimconnect 0 comments
blog.KimConnect.com >> Windows >> PowerShell: Script to Obtain List of Sites and Associated Domain Controllers

Script:

if (!(get-module -name "ActiveDirectory") ){Add-WindowsFeature RSAT-AD-PowerShell; import-module -name "ActiveDirectory" -DisableNameChecking | out-null }
$sites=(Get-ADDomainController -filter * | select ServerObjectDN) | foreach-object -process {$_ | ConvertFrom-String -Delimiter "," | select P1,P3} | foreach-object {$a=$_.P1 -replace "@{ServerObjectDN=CN=";$b=$_.P3 -replace "CN=";$b+","+$a;} | Sort-Object | foreach-object -process {$_ | ConvertFrom-String -Delimiter ","} | Group-Object P1
foreach ($site in $sites){
$site.Name+": "+$site.Group.P2
}

Output:

Irvine: SHERVER1 SHERVER2
Irvine-PublicDMZ: SHERVER3 SHERVER4
Phoenix: DC5 DC6
Phoenix-PublicDMZ: DC6 DC7
Phoenix-WebDMZ: DC8 DC9
Florida: DC10 DC11

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

Storage & Transfer Speed Unit of Measurement

Intro What's all this talk about bits and bytes? Why do hard drive manufacturers measure…

Exchange: New-MoveRequest

New-MoveRequest -Identity '[email protected]' -TargetDatabase "DB01" -WhatIfNew-MoveRequest -Identity '[email protected]' -TargetDatabase "DB01"Get-Mailbox -Database DB01 | New-MoveRequest -TargetDatabase…

R5 2400G Zen CPU Cores Undervolt and Overclocking

Some quick tested values: 3600 Mhz | 1.225 mV ~ 70 Watts (need to also…