Sysvol Data Source

Microsoft.Windows.Server.2012.R2.AD.Availability.SysVol.DataSource (DataSourceModuleType)

Sysvol Data Source

Knowledge Base article:

Additional

The health of the Sysvol shared folder is essential to the Domain Controller. Sysvol is a shared folder on every domain controller that stores a copy of the domain’s public files, including system policies and Group Policy settings, which are replicated to all other domain controllers in the domain. SYSVOL share problems prevent Group Policy and login scripts from working.

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
OutputTypeSystem.PropertyBagData

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource System.CommandExecuterPropertyBagSource Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
IntervalSecondsint$Config/IntervalSeconds$FrequencyHow often the monitor is run
TimeoutSecondsint$Config/IntervalSeconds$TimeoutTime out in Sec

Source Code:

<DataSourceModuleType ID="Microsoft.Windows.Server.2012.R2.AD.Availability.SysVol.DataSource" Accessibility="Internal" Batching="false">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="IntervalSeconds" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="TimeoutSeconds" type="xsd:integer"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/IntervalSeconds$" 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/AD_Sysvol_Share_DataSource.vbs$</CommandLine>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
<RequireOutput>true</RequireOutput>
<Files>
<File>
<Name>AD_Sysvol_Share_DataSource.vbs</Name>
<Contents><Script>Option Explicit
SetLocale("en-us")

'*************************************************************************
' Script Name - AD Sysvol Share Data Source
'*************************************************************************
Function Initialize(ByRef oAPI, ByRef oBag, ByRef oWMI)
Set oAPI = CreateObject("Mom.ScriptAPI")
If Err &lt;&gt; 0 Then
Quit -1
End If
Set oBag = oAPI.CreatePropertyBag()
If Err &lt;&gt; 0 Then
Initialize = 1
Exit Function
End If
Set oWMI = GetObject("winmgmts:{impersonationLevel=impersonate}")
If Err &lt;&gt; 0 Then
Initialize = 2
Exit Function
End If
Initialize = 0
End Function

'*************************************************************************
' CreateErrorEvent
'*************************************************************************
Sub CreateErrorEvent(ByVal eid, ByRef oAPI)
Dim strMsg
strMsg = GetErrorMessage(eid)
Call oAPI.LogScriptEvent("AD_Sysvol_Share_DataSource.vbs", 1000, 1, strMsg)
End Sub

'*************************************************************************
' GetErrorMessage
'*************************************************************************
Function GetErrorMessage(ByVal eid)
Dim strMsg
Select Case eid
Case 1 strMsg = "Cannot create propertybag. oAPI.CreatePropertyBag() failed."
Case 2 strMsg = "Cannot create WMI object."
Case 3 strMsg = "WMI query failed."
End Select
GetErrorMessage = strMsg
End Function

'*************************************************************************
' ExecuteQuery
'*************************************************************************
Function ExecuteQuery(ByRef strQuery, ByRef oWMI, ByRef oResult, ByRef oAPI)
Set oResult = oWMI.ExecQuery(strQuery)
If Err &lt;&gt; 0 Then
ExecuteQuery = 3
Exit Function
End If
ExecuteQuery = 0
End Function

'*************************************************************************
'
' Main
'
'*************************************************************************
Sub Main()
Dim iResult
Dim oAPI
Dim oBag
Dim oWMI
Dim strQuery
Dim oResult

strQuery = "Select status from Win32_Share Where Name='SYSVOL'"
iResult = Initialize(oAPI, oBag, oWMI)
If iResult &lt;&gt; 0 Then
CreateErrorEvent iResult, oAPI
Exit Sub
End If
iResult = ExecuteQuery(strQuery, oWMI, oResult, oAPI)
If iResult &lt;&gt; 0 Then
CreateErrorEvent iResult, oAPI
Exit Sub
End If
If oResult.Count = 0 Then
oBag.AddValue "Status", "BAD"
Else
oBag.AddValue "Status", "GOOD"
End If
oAPI.Return oBag
End Sub

Call Main()
</Script></Contents>
<Unicode>1</Unicode>
</File>
</Files>
</DataSource>
</MemberModules>
<Composition>
<Node ID="DS"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.PropertyBagData</OutputType>
</DataSourceModuleType>