This small powershell command helps you to get the domain controller name currently in use.
PS C:> ([ADSI]”LDAP://RootDSE”).dnshostname
You can also know to which site this DC belongs to.
PS C:> ([ADSI]”LDAP://RootDSE”).servername.tostring().split(“,”).Split(“=”)[
Isn’t it looking a bit complex to query the site name? Any alternatives? Yes, we do have one. Below helps you to query the Site name of DC you connected.
Get-ADDomainController -Discover | select Site
Note that above command requries ActiveDirectory PowerShell module which is generally available in Windows 7. One more requirement to make ActiveDirectory Module work agaist your Active Directory is, your DCs should have ADWS(active directory web services) installed. These services comes by default with windows 2008 servers but on windows 2003 servers you need to install this additional components.
Refer to my old article about Active Directory Administrative Center where I talked about ADWS for windows 2003.