Работоспособность общего ресурса Sysvol важна для работы контроллера домена. Sysvol представляет собой общую папку на каждом контроллере домена, в которой хранятся копии общих файлов домена, включая системные политики и параметры групповой политики для репликации на всех остальных контроллерах доменов в этом домене. Неполадки в работе общего ресурса SYSVOL приводят к нарушению работы групповой политики и сценариев входа.
'*************************************************************************
' 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