A. I've written a short VBScript script called localsrvroles.vbs that displays on screen the FSMO roles that the current server holds. (My script is based on a script that Microsoft created to list all the roles of a forest; I've changed the Microsoft script to compare these roles to the local server's roles and display only the roles that match.) Localsrvroles.vbs, which is available at the Windows & .NET Magazine Web site, is listed below.

Option Explicit
Dim WSHNetwork, objArgs, ADOconnObj, bstrADOQueryString, RootDom, RSObj
Dim FSMOobj,CompNTDS, Computer, Path, HelpText, LocalDNSName, strComputerDN, objSysInfo, objComputer

Set WSHNetwork = CreateObject("WScript.Network")
Path = WSHNetwork.ComputerName

Set objSysInfo = CreateObject("ADSystemInfo")
strComputerDN = objSysInfo.ComputerName

Set objComputer = GetObject("LDAP://" & strComputerDN)
LocalDNSName = objComputer.dNSHostName

Set ADOconnObj = CreateObject("ADODB.Connection")

ADOconnObj.Provider = "ADSDSOObject"
ADOconnObj.Open "ADs Provider"

'PDC FSMO
bstrADOQueryString = ";(&(objectClass=domainDNS)(fSMORoleOwner=*));adspath;subtree"
Set RootDom = GetObject("LDAP://RootDSE")
Set RSObj = ADOconnObj.Execute(bstrADOQueryString)
Set FSMOobj = GetObject(RSObj.Fields(0).Value)
Set CompNTDS = GetObject("LDAP://" & FSMOobj.fSMORoleOwner)
Set Computer = GetObject(CompNTDS.Parent)
if StrComp(LocalDNSName, Computer.dnsHostName) = 0 then
WScript.Echo "PDC"
end if

'Rid FSMO
bstrADOQueryString = ";(&(objectClass=rIDManager)(fSMORoleOwner=*));adspath;subtree"

Set RSObj = ADOconnObj.Execute(bstrADOQueryString)
Set FSMOobj = GetObject(RSObj.Fields(0).Value)
Set CompNTDS = GetObject("LDAP://" & FSMOobj.fSMORoleOwner)
Set Computer = GetObject(CompNTDS.Parent)
if StrComp(LocalDNSName, Computer.dnsHostName) = 0 then
WScript.Echo "RIS"
end if

'Infrastructure FSMO
bstrADOQueryString = ";(&(objectClass=infrastructureUpdate)(fSMORoleOwner=*));adspath;subtree"

Set RSObj = ADOconnObj.Execute(bstrADOQueryString)
Set FSMOobj = GetObject(RSObj.Fields(0).Value)
Set CompNTDS = GetObject("LDAP://" & FSMOobj.fSMORoleOwner)
Set Computer = GetObject(CompNTDS.Parent)
if StrComp(LocalDNSName, Computer.dnsHostName) = 0 then
WScript.Echo "Infrastructure"
end if

'Schema FSMO
bstrADOQueryString = " ">;(&(objectClass=dMD)(fSMORoleOwner=*));adspath;subtree"

Set RSObj = ADOconnObj.Execute(bstrADOQueryString)
Set FSMOobj = GetObject(RSObj.Fields(0).Value)
Set CompNTDS = GetObject("LDAP://" & FSMOobj.fSMORoleOwner)
Set Computer = GetObject(CompNTDS.Parent)
if StrComp(LocalDNSName, Computer.dnsHostName) = 0 then
WScript.Echo "Schema"
end if

'Domain Naming FSMO
bstrADOQueryString = " ">;(&(objectClass=crossRefContainer)(fSMORoleOwner=*));adspath;subtree"

Set RSObj = ADOconnObj.Execute(bstrADOQueryString)
Set FSMOobj = GetObject(RSObj.Fields(0).Value)
Set CompNTDS = GetObject("LDAP://" & FSMOobj.fSMORoleOwner)
Set Computer = GetObject(CompNTDS.Parent)
if StrComp(LocalDNSName, Computer.dnsHostName) = 0 then
WScript.Echo "Domain Naming"
end if

To execute the script, at the command prompt type

cscript //nologo localsrvroles.vbs

The script output will look similar to the following:

PDC
RIS
Infrastructure
Schema
Domain Naming

Notice that the script doesn't output anything except the roles that the machine holds (in this case, the server holds all five FSMO roles).