Skip navigation

JSI Tip 7401. How can I test a domain controller for a specific FSMO role?

Active Directory defines five FSMO (Flexible Single-Master Operations) roles:

Schema master
Domain naming master
RID master
PDC emulator
Infrastructure

The schema master and domain naming master are per-forest roles. The remaining three, RID master, PDC emulator, and infrastructure master, are per-domain roles.

I have scripted IsRole.bat to test a specified server for a given role.

The syntax for using IsRole.bat is:

call isrole ServerName Role Answer

where:

ServerName is the NetBIOS name of the server, with or without the leading \\.

Role       is the one of the following, and is NOT case sensitive:
                  Schema
                  Domain
                  PDC
                  RID
                  Infrastructure

Answer     is a call directed environment variable that will contain
                  a Y if the server holds the Role,
                  a N if the server does NOT hold the Role, or
                  a X if the server could not be contacted.
IsRole.bat contains:
@echo off
if ""=="%3" goto usage
setlocal ENABLEDELAYEDEXPANSION
set ans=N
set role=%2
set role="%role:"=%"
set run=Ntdsutil roles Connections "Connect to server %1" Quit "select Operation Target" "List roles for connected server" Quit Quit Quit 
for /f "Skip=4 Tokens=1" %%r in ('%run%') do if "!ans!" EQU "N" call :testrole "%%r"
endlocal&set %3=%ans%
goto :EOF
:testrole
if "%ans%" EQU "X" goto :EOF
if /i %1 EQU "DsBindW" set ans=X&goto :EOF
if /i %1 EQU %role% set ans=Y
goto :EOF
:usage
@echo Syntax: IsRole ServerName Role Answer



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