<DataSourceModuleType ID="Microsoft.Windows.Server.2012.AD.Configuration.FsmoHolders.DataSource" Accessibility="Internal" Batching="false">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="IntervalSeconds" type="xsd:int"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TimeoutSeconds" type="xsd:int"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="FsmoType" type="xsd:int"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
<OverrideableParameter ID="FsmoType" Selector="$Config/FsmoType$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<DataSource ID="DS" TypeID="System!System.CommandExecuterPropertyBagSource">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<ApplicationName>%windir%\system32\cscript.exe</ApplicationName>
<WorkingDirectory/>
<CommandLine>//nologo $file/FSMO_Consistency.vbs$ $Config/FsmoType$ </CommandLine>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
<RequireOutput>true</RequireOutput>
<Files>
<File>
<Name>FSMO_Consistency.vbs</Name>
<Contents><Script>'*************************************************************************
' Script Name - FSMO Consistency
'
' Purpose - Monitors that FSMO holders on the DC match what is on the PDC
'
' (c) Copyright 2014, Microsoft Corporation, All Rights Reserved
' Proprietary and confidential to Microsoft Corporation
'*************************************************************************
Option Explicit
SetLocale("en-us")
Sub Main()
Dim oAPI, oBag, oParams, sError, oRootDSE, oDomain, oFsmo, sFsmoHolderName, sPDC, sFsmoName
Dim iFsmoType, oNtds, oFsmoHolder
Set oAPI = CreateObject("Mom.ScriptAPI")
Set oBag = oAPI.CreatePropertyBag()
Set oParams = WScript.Arguments
if oParams.Count <> 1 then
sError = "The number of command line arguments is incorrect: " & vbCrLf & _
"Expected: 1" & vbCrLf & _
"Actual: " & oParams.Count
if iFsmoType > 4 or iFsmoType < 1 then
iFsmoType = 1
End if
' Get the PDC name
Set oRootDSE = GetObject("LDAP://rootDSE")
Set oDomain = GetObject ("LDAP://" & oRootDSE.Get("defaultNamingContext"))
oFsmo = oDomain.Get("fSMORoleOwner")
Set oNtds = GetObject("LDAP://" & oFsmo)
Set oFsmoHolder = GetObject(oNtds.Parent)
sPdc = oFsmoHolder.dnsHostName
' Now get the holder of the FSMO according to the local DC
If iFsmoType = 1 Then
Set oDomain = GetObject("LDAP://CN=Partitions," & oRootDSE.Get("configurationNamingContext"))
sFsmoName = "Domain Naming Master"
ElseIf iFsmoType = 2 Then
Set oDomain = GetObject ("LDAP://" & oRootDSE.Get("schemaNamingContext"))
sFsmoName = "Schema Master"
ElseIf iFsmoType = 3 Then
Set oDomain = GetObject("LDAP://CN=RID Manager$,CN=System," & oRootDSE.Get("defaultNamingContext"))
sFsmoName = "RID Master"
Else
Set oDomain = GetObject("LDAP://CN=Infrastructure," & oRootDSE.Get("defaultNamingContext"))
sFsmoName = "Infrastructure Master"
End If
oFsmo = oDomain.Get("fSMORoleOwner")
Set oNtds = GetObject("LDAP://" & oFsmo)
Set oFsmoHolder = GetObject(oNtds.Parent)
sFsmoHolderName = oFsmoHolder.dnsHostName
' Finally get the holder of th FSMO according to the PDC
Set oRootDSE = GetObject("LDAP://" & sPdc & "/rootDSE")
If iFsmoType = 1 Then
Set oDomain = GetObject("LDAP://CN=Partitions," & oRootDSE.Get("configurationNamingContext"))
ElseIf iFsmoType = 2 Then
Set oDomain = GetObject ("LDAP://" & oRootDSE.Get("schemaNamingContext"))
ElseIf iFsmoType = 3 Then
Set oDomain = GetObject("LDAP://CN=RID Manager$,CN=System," & oRootDSE.Get("defaultNamingContext"))
Else
Set oDomain = GetObject("LDAP://CN=Infrastructure," & oRootDSE.Get("defaultNamingContext"))
End If
oFsmo = oDomain.Get("fSMORoleOwner")
Set oNtds = GetObject("LDAP://" & oFsmo)
Set oFsmoHolder = GetObject(oNtds.Parent)
If (oFsmoHolder.dnsHostName <> sFsmoHolderName) Then
oBag.AddValue "State", "BAD"
oBag.AddValue "ErrorString", "The PDC and local DC do not agree on the owner of the FSMO: " & sFsmoName & vbCrLf & _
"PDC: " & oFsmoHolder.DnsHostName & vbCrLf & _
"Local DC: " & sFsmoHolderName
oAPI.AddItem oBag
Else
oBag.AddValue "State", "GOOD"
oAPI.AddItem oBag
End If