JSI Tip 6987. How can a batch file determine if a domain controller is available?
Jerold Schulman
July 28, 2003
1 Min Read
I have scripted GetDC.bat to return a call directed environment variable with the name of a domain controller in the specified domain, or NO, if a domain controller cannot be located.
The syntax for using GetDC.bat is:
call getdc DomainName DomainController
where DomainName is the name of the domain you are interrogating
and DomainController is the call directed environment variable that will contain \DomainControllerComputerName, if you used a NetBIOS domain name,
or\DomainControllerComputerName.DNSDomainName (like \JSI001.JSIINC.COM) if you used a DNS domain name.
GetDC.bat contains:
@echo offif {%2}
{} @echo Syntax: Call GetDC DomainName DomainController&goto :EOFset %2=NOfor /f "Tokens=1*" %%a in ('nltest /dsgetdc:%1') do if /i "%%a"
"DC:" set %2=%%b
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