Get the IsTG and BHS DC of each site in your Active Directory Domain

Hello,

You can get the “IsTG” and “BHS” domain controller of each site with that query :

$SiteSearcher = [ADSISearcher]"objectclass=site"
$dse = [adsi]"LDAP://RootDSE"
$ConfPart=$dse.configurationNamingContext
$SiteSearcher.SearchRoot = [ADSI]"LDAP://$ConfPart"
$Sites=$SiteSearcher.FindAll()
ForEach($Site in $Sites){
    #Ntds Site Settings
    [String]$NtdsSiteSettingsDN="CN=NTDS Site Settings,"+$Site.Properties.distinguishedname
    $NtdsSiteSettings=[ADSI]"LDAP://$NtdsSiteSettingsDN"

    New-Object -TypeName PSObject -Property @{
        'Subnet'      = $Site.Properties.siteobjectbl | % {(($_ -replace 'CN=',',') -split ',')[1]}
        'Site'        = $($Site.Properties.name)
        'Description' = $($Site.Properties.description)
        'IsTG'        = ($NtdsSiteSettings.properties.interSiteTopologyGenerator -split ',CN=')[1]
        'BHS'         = $NtdsSiteSettings.properties.bridgeheadServerListBL
    }
}

This snippet does not require the Active Directory module, and works on PowerShell 2.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.