Techibee.com

Tip: Get the domain controller details using PowerShell

 

This small powershell command helps you to get the domain controller name currently in use.

PS C:> ([ADSI]”LDAP://RootDSE”).dnshostname
DC1.Techibee.com
PS C:>

You can also know to which site this DC belongs to.

PS C:> ([ADSI]”LDAP://RootDSE”).servername.tostring().split(“,”)[2].Split(“=”)[
1]
SITE1
PS C:>

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.

import-module ActiveDirectory

Get-ADDomainController -Discover | select Site

Site
—–
SITE1

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.

Exit mobile version