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.
'*************************************************************************
' Script Name - AD Sysvol Share Data Source
'*************************************************************************
Function Initialize(ByRef oAPI, ByRef oBag, ByRef oWMI)
Set oAPI = CreateObject("Mom.ScriptAPI")
If Err <> 0 Then
Quit -1
End If
Set oBag = oAPI.CreatePropertyBag()
If Err <> 0 Then
Initialize = 1
Exit Function
End If
Set oWMI = GetObject("winmgmts:{impersonationLevel=impersonate}")
If Err <> 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 <> 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 <> 0 Then
CreateErrorEvent iResult, oAPI
Exit Sub
End If
iResult = ExecuteQuery(strQuery, oWMI, oResult, oAPI)
If iResult <> 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