A PDC ping rendelkezésre állási parancsfájljának adatforrása

Microsoft.Windows.AD.DomainMemberPerspective.Availability.PDC.Ping.DataSource (DataSourceModuleType)

Adatforrás a PDC ping rendelkezésre állásának figyelőihez.

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$Intervallum hossza (s)
PingIterationsint$Config/PingIterations$A pingelési kísérlet sikertelen ismétléseinek azon száma, amely már riasztást vált ki
TimeoutSecondsint$Config/TimeoutSeconds$Időtúllépés hossza (s)

Source Code:

<DataSourceModuleType ID="Microsoft.Windows.AD.DomainMemberPerspective.Availability.PDC.Ping.DataSource" Accessibility="Internal">
<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="PingIterations" type="xsd:int"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TimeoutSeconds" type="xsd:int"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" ParameterType="int" Selector="$Config/IntervalSeconds$"/>
<OverrideableParameter ID="PingIterations" ParameterType="int" Selector="$Config/PingIterations$"/>
<OverrideableParameter ID="TimeoutSeconds" ParameterType="int" Selector="$Config/TimeoutSeconds$"/>
</OverrideableParameters>
<ModuleImplementation>
<Composite>
<MemberModules>
<DataSource ID="DS" TypeID="System!System.CommandExecuterPropertyBagSource">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<ApplicationName>%windir%\system32\cscript.exe</ApplicationName>
<WorkingDirectory/>
<CommandLine>//nologo $file/PDC_Ping_Availability.vbs$ $Config/PingIterations$</CommandLine>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
<RequireOutput>true</RequireOutput>
<Files>
<File>
<Name>PDC_Ping_Availability.vbs</Name>
<Contents><Script>'*************************************************************************
' Script Name - PDC Ping Availability
'
' Purpose - Monitors that pings to the PDC holder respond
'
' (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
Dim oPing, oStatus, oNtds, oFsmoHolder, iIteration, iMaxIterations

Set oAPI = CreateObject("Mom.ScriptAPI")
Set oBag = oAPI.CreatePropertyBag()
Set oParams = WScript.Arguments

if oParams.Count &lt;&gt; 1 then
sError = "The number of command line arguments is incorrect: " &amp; vbCrLf &amp; _
"Expected: 1" &amp; vbCrLf &amp; _
"Actual: " &amp; oParams.Count

oBag.AddValue "State", "BAD"
oBag.AddValue "ErrorString", sError

Call oAPI.Return(oBag)
Exit Sub
End if

iMaxIterations = CInt(oParams(0))

if iMaxIterations &lt; 1 then
iMaxIterations = 3
End if

On Error Resume Next

Set oRootDSE = GetObject("LDAP://rootDSE")

If (Err.Number &lt;&gt; 0) Then
oBag.AddValue "State", "BAD"
oBag.AddValue "ErrorString", "Unable to bind to the rootDSE." &amp; GetErrorString(Err)
oAPI.AddItem oBag

Call oAPI.Return(oBag)
Exit Sub
End if

Set oDomain = GetObject ("LDAP://" &amp; oRootDSE.Get("defaultNamingContext"))

If (Err.Number &lt;&gt; 0) Then
oBag.AddValue "State", "BAD"
oBag.AddValue "ErrorString", "Unable to get the defaultNamingContext naming context." &amp; GetErrorString(Err)
oAPI.AddItem oBag

Call oAPI.Return(oBag)
Exit Sub
End if

oFsmo = oDomain.Get("fSMORoleOwner")

If (Err.Number &lt;&gt; 0) Then
oBag.AddValue "State", "BAD"
oBag.AddValue "ErrorString", "Unable to get the fSMORoleOwner property." &amp; GetErrorString(Err)
oAPI.AddItem oBag

Call oAPI.Return(oBag)
Exit Sub
End if

Set oNtds = GetObject("LDAP://" &amp; oFsmo)

If (Err.Number &lt;&gt; 0) Then
oBag.AddValue "State", "BAD"
oBag.AddValue "ErrorString", "Unable to connect to the FSMO owner " &amp; oFsmo &amp; "." &amp; GetErrorString(Err)
oAPI.AddItem oBag

Call oAPI.Return(oBag)
Exit Sub
End if

Set oFsmoHolder = GetObject(oNtds.Parent)

For iIteration = 0 to iMaxIterations
Set oPing = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_PingStatus where address = '" &amp; oFsmoHolder.dnsHostName &amp; "'")

For Each oStatus in oPing
If not IsNull(oStatus.StatusCode) and oStatus.StatusCode = 0 Then
oBag.AddValue "State", "GOOD"
oAPI.AddItem oBag

Call oAPI.Return(oBag)
Exit Sub
End If
Next
Next

oBag.AddValue "State", "BAD"
oBag.AddValue "ErrorString", "Unable to ping the FSMO holder " &amp; oFsmoHolder.dnsHostName
oAPI.AddItem oBag

oAPI.ReturnItems

End Sub

'******************************************************************************
' Name: GetErrorString
'
' Purpose: Attempts to find the description for an error if an error with
' no description is passed in.
'
' Parameters: oErr, the error object
'
' Return: String, the description for the error. (Includes the error code.)
'
Function GetErrorString(oErr)
Dim lErr, strErr
lErr = oErr
strErr = oErr.Description

On Error Resume Next
If 0 &gt;= Len(strErr) Then
' If we don't have an error description, then check to see if the error
' is a 0x8007xxxx error. If it is, then look it up.
Const ErrorMask = &amp;HFFFF0000
Const HiWord8007 = &amp;H80070000
Const LoWordMask = 65535 ' This is equivalent to 0x0000FFFF

If (lErr And ErrorMask) = HiWord8007 Then
' Attempt to use 'net helpmsg' to get a description for the error.
Dim oShell
Set oShell = CreateObject("WScript.Shell")
If Err = 0 Then
Dim oExec
Set oExec = oShell.Exec("net helpmsg " &amp; (lErr And LoWordMask))

Dim strMessage, i
Do
strMessage = oExec.stdout.ReadLine()
i = i + 1
Loop While (Len(strMessage) = 0) And (i &lt; 5)

strErr = strMessage
End If
End If
End If

GetErrorString = vbCrLf &amp; vbCrLf &amp; "The error returned was: '" &amp; strErr &amp; "' (0x" &amp; Hex(lErr) &amp; ")"
End Function

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