WMI: Scripting DSQUERY to report FSMO roles
This script executes a series of "dsquery" commands to determine which servers house the FSMO roles on your network. This will later be incorporated as a function into my inventory script.
Dim objShell
Set objShell = CreateObject("WScript.Shell")
strCmdRun = "cmd /c"
strQuery = "dsquery server -hasfsmo "
strQuerySchema = "schema"
strQueryRID = "rid"
strQueryName = "name"
strQueryInfr = "infr"
strQueryPDC = "PDC"
Set objExec = objShell.Exec(strCmdRun & strQuery & strQuerySchema)
strExecResultsSchema = LCase(objExec.StdOut.ReadAll)
Set objExec = objShell.Exec(strCmdRun & strQuery & strQueryRID)
strExecResultsRID = LCase(objExec.StdOut.ReadAll)
Set objExec = objShell.Exec(strCmdRun & strQuery & strQueryName)
strExecResultsName = LCase(objExec.StdOut.ReadAll)
Set objExec = objShell.Exec(strCmdRun & strQuery & strQueryInfr)
strExecResultsInfr = LCase(objExec.StdOut.ReadAll)
Set objExec = objShell.Exec(strCmdRun & strQuery & strQueryPDC)
strExecResultsInfr = LCase(objExec.StdOut.ReadAll)
Wscript.Echo "FSMO Roles: "
Wscript.Echo "-----------"
Wscript.Echo "Schema Master: " & strExecResultsSchema
Wscript.Echo " "
Wscript.Echo "RID Master: " & strExecResultsRID
Wscript.Echo " "
Wscript.Echo "Domain Naming Master: " & strExecResultsName
Wscript.Echo " "
Wscript.Echo "Infrastructure Role: " & strExecResultsInfr
Wscript.Echo " "
Wscript.Echo "PDC Emulator: " & strExecResultsInfr
No comments:
Post a Comment