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 off
if \{%2\}<h1><a name="_echo_Syntax_Call_GetDC_DomainName_DomainController_amp_goto_EOF_set_2_NO_for_f_Tokens_1_a_in_nltest_dsgetdc_1_do_if_i_a_">\{\} @echo Syntax: Call GetDC DomainName DomainController&goto :EOF
set %2=NO
for /f "Tokens=1*" %%a in ('nltest /dsgetdc:%1') do if /i "%%a"</a></h1>"DC:" set %2=%%b