Identify which Active Directory domain controllers are providing the five FSMO roles: Schema Master, Domain Naming Master, PDC Emulator, RID Master, and Infrastructure Master.
Set objRootDSE = GetObject("LDAP://rootDSE")' Schema MasterSet objSchema = GetObject("LDAP://" & objRootDSE.Get("schemaNamingContext"))strSchemaMaster = objSchema.Get("fSMORoleOwner")Set objNtds = GetObject("LDAP://" & strSchemaMaster)Set objComputer = GetObject(objNtds.Parent)WScript.Echo "Forest-wide Schema Master FSMO: " & objComputer.NameSet objNtds = NothingSet objComputer = Nothing' Domain Naming MasterSet objPartitions = GetObject("LDAP://CN=Partitions," & _objRootDSE.Get("configurationNamingContext"))strDomainNamingMaster = objPartitions.Get("fSMORoleOwner")Set objNtds = GetObject("LDAP://" & strDomainNamingMaster)Set objComputer = GetObject(objNtds.Parent)WScript.Echo "Forest-wide Domain Naming Master FSMO: " & objComputer.NameSet objNtds = NothingSet objComputer = Nothing' PDC EmulatorSet objDomain = GetObject("LDAP://" & objRootDSE.Get("defaultNamingContext"))strPdcEmulator = objDomain.Get("fSMORoleOwner")Set objNtds = GetObject("LDAP://" & strPdcEmulator)Set objComputer = GetObject(objNtds.Parent)WScript.Echo "Domain's PDC Emulator FSMO: " & objComputer.NameSet objNtds = NothingSet objComputer = Nothing' RID MasterSet objRidManager = GetObject("LDAP://CN=RID Manager$,CN=System," & _objRootDSE.Get("defaultNamingContext"))strRidMaster = objRidManager.Get("fSMORoleOwner")Set objNtds = GetObject("LDAP://" & strRidMaster)Set objComputer = GetObject(objNtds.Parent)WScript.Echo "Domain's RID Master FSMO: " & objComputer.NameSet objNtds = NothingSet objComputer = Nothing' Infrastructure MasterSet objInfrastructure = GetObject("LDAP://CN=Infrastructure," & _objRootDSE.Get("defaultNamingContext"))strInfrastructureMaster = objInfrastructure.Get("fSMORoleOwner")Set objNtds = GetObject("LDAP://" & strInfrastructureMaster)Set objComputer = GetObject(objNtds.Parent)WScript.Echo "Domain's Infrastructure Master FSMO: " & objComputer.Name
This is a VB Script, this can be used by saving the file in .vbs file