Skip navigation

JSI Tip 9542. How can a batch script return the name of the PDC in the logged on user's domain?

Using the Nltest.exe utility from the Support Tools on the operating system CD-ROM, I have scripted GetPDC.bat to return the NetBIOS PDC name.

The syntax for using GetPDC.bat is:

call GetPDC PDC

Where PDC is a call directed environment variable that will contain the NetBIOS PDC name.

GetPDC.bat contains:

@echo off
if \{%1\}==\{\} @echo Syntax: call GetPDC PDC&goto :EOF
set %1=NONE
for /f "Tokens=1* Delims=\" %%a in ('nltest /DCNAME:"%USERDOMAIN%"^|FIND "PDC"') do (
 set %1=%%b
)



Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish