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

Where:

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"                              :doit                              for /f "Tokens=*" %%s in ('cscript //nologo "%TEMP%\DCSite.vbs" %1') do (                               set %2=%%s                              )