In tip 7670, I used RepAdmin.exe to script ISGC.bat.
Using DSQUERY, an Active Directory command-line tool, I have scripted another version of ISGC.bat to test if a server is a Global Catalog server.
The syntax for using ISGC.bat is:
call ISGC ServerName GCVar
Where ServerName is the NetBIOS name of the domain controller, and GCVar is a call directed environment variable that will be set to:
X if the server is not found, or is not a domain controller.
Y if the domain controller is a Global Catalog server.
N if the domain controller is NOT a Global Catalog server.
ISGC.bat contains:
@echo off if \{%2\}==\{\} @echo Syntax: ISGC ServerName GCVar&exit /b 1 :: Initialize GCVar to X (NOT Found or NOT a DC). set %2=X for /f "Tokens=*" %%s in ('dsquery server -domain "%USERDNSDOMAIN%" -name %1') do ( :: Server is found. set %2=N for /f "Tokens=*" %%g in ('dsquery server -domain "%USERDNSDOMAIN%" -name %1 -isgc') do ( :: Server is a Global Catalog Server. set %2=Y ) )
0 comments
Hide comments