JSI Tip 5629. How can my script detect if a remote computer is a Active Directory domain controller?
Jerold Schulman
August 15, 2002
1 Min Read
In tip 0134, we used the net accounts command to determine the role of the local computer. It would return WORKSTATION, SERVER, or PRIMARY.
We could script the detection of the local computers role using:
for /f "skip=8 Tokens=3" %i in ('net accounts') do if /i NOT "%i"=="completed" set role=%i
To detect if a remote computer is an Active Directory domain controller, you can test for the NTDS service key, using Reg.exe from the Windows 2000 Support Tools, or Reg.exe that is built into Windows XP and later:
"C:Program FilesSupport Toolsreg.exe" query "\HKEY_LOCAL_MACHINESystemCurrentControlSetServicesNTDS">nul 2>&1if %ERRORLEVEL% EQU 1 goto NotDC
About the Author
Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.
You May Also Like