JSI Tip 10462. Another way to determine the SITE that a Domain Controller is located in?

In tip 3093, we used Nltest.exe to determine What SITE is a Domain Controller was located in.

Using only native commands, I have scripted DCSite.bat to determine the SITE of a specified domain controller.

The syntax for using DCSite.bat is:

\[Call\] DCSite NetBIOSDCName SiteName


NetBIOSDCName is the NetBIOS computer name of a domain controller.

SiteName      is a call directed environment variable that will contain the SITE that NetBIOSDCName belongs to.
DCSite.bat contains:
@echo off
if \{%2\}==\{\} @echo Syntax: DCSite NetBIOSDCName SiteName&goto :EOF
if exist "%TEMP%\DCSite.vbs" goto doit
@echo dcName = Wscript.Arguments(0)>"%TEMP%\DCSite.vbs"
@echo set obj = CreateObject("ADSystemInfo")>>"%TEMP%\DCSite.vbs"
@echo Wscript.Echo obj.GetDCSiteName(dcName)>>"%TEMP%\DCSite.vbs"
for /f "Tokens=*" %%s in ('cscript //nologo "%TEMP%\DCSite.vbs" %1') do (
 set %2=%%s

Hide 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.