Microsoft Windows Server DNS Monitoring Control Zone WA

Microsoft.Windows.Server.DNS.ControlZone.WA (WriteActionModuleType)

Script Write Action that terforms multiple zone control actions

Element properties:

TypeWriteActionModuleType
IsolationAny
AccessibilityPublic
RunAsDefault
InputTypeSystem.BaseData
OutputTypeSystem.CommandOutput

Member Modules:

ID Module Type TypeId RunAs 
WA WriteAction Microsoft.Windows.ScriptWriteAction Default

Source Code:

<WriteActionModuleType ID="Microsoft.Windows.Server.DNS.ControlZone.WA" Accessibility="Public" Batching="false">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="Server" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="Zone" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="Action" type="xsd:string"/>
</Configuration>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<WriteAction ID="WA" TypeID="Windows!Microsoft.Windows.ScriptWriteAction">
<ScriptName>Microsoft.Windows.Server.DNS.ControlZone.WA.vbs</ScriptName>
<Arguments>$Config/Server$ $Config/Zone$ $Config/Action$</Arguments>
<ScriptBody><Script>'Copyright (c) Microsoft Corporation. All rights reserved.

'*************************************************************************
' ScriptName: Microsoft.Windows.Server.DNS.ControlZone.WA
'
' Purpose: DNS Server DNS Control Zone Write Action
'
' File: Microsoft.Windows.Server.DNS.ControlZone.WA.vbs
'*************************************************************************

Option Explicit

SetLocale("en-us")

Const SCRIPT_NAME = "Microsoft.Windows.Server.DNS.ControlZone.WA"

Dim strServer, strZone, strCommand
Dim objDNSWMI, colZones, objZone

strServer = WScript.Arguments(0)
strZone = WScript.Arguments(1)
strCommand = WScript.Arguments(2)

On Error Resume Next
Set objDNSWMI = GetObject("winmgmts:\\" &amp; strServer &amp; "\root\MicrosoftDNS")
If Err &lt;&gt; 0 Then Call ThrowScriptErrorAndAbort("Unable to connect to MicrosoftDNS namespace.")

Set colZones = objDNSWMI.ExecQuery("Select * from MicrosoftDNS_Zone where name = '" &amp; strZone &amp; "'")
If (Err &lt;&gt; 0) Then Call ThrowScriptErrorAndAbort("Unable to identify specified zone.")
If (colZones.Count=0) Then Call ThrowScriptErrorAndAbort("Zone not found.")

For Each objZone In colZones

Select Case lcase(strCommand)
Case "pause"
objZone.PauseZone
Case "resume"
objZone.ResumeZone
Case "reload"
objZone.ReloadZone
Case "refresh"
objZone.ForceRefresh
Case "update"
objZone.UpdateFromDS
Case Else
Call ThrowScriptErrorAndAbort("Bad command specified.")
End Select

If Err &lt;&gt; 0 Then Call ThrowScriptErrorAndAbort("Unable to perform specified action.")

strMessage = ""
strMessage = strMessage &amp; SCRIPT_NAME &amp; " completed successfully." &amp; VbCrLf
strMessage = strMessage &amp; "Zone: " &amp; strZone &amp; VbCrLf
strMessage = strMessage &amp; "Command: " &amp; strCommand &amp; VbCrLf

WScript.Echo strMessage

Next



Sub ThrowScriptErrorAndAbort(strMessageArg)
Dim strMessage
strMessage = ""
strMessage = strMessage &amp; SCRIPT_NAME &amp; " completed with an error." &amp; VbCrLf
strMessage = strMessage &amp; strMessageArg &amp; VbCrLf
strMessage = strMessage &amp; "Server: " &amp; strServer &amp; VbCrLf
strMessage = strMessage &amp; "Zone: " &amp; strZone &amp; VbCrLf
strMessage = strMessage &amp; "Command: " &amp; strCommand &amp; VbCrLf

If Err &lt;&gt; 0 Then strMessage = strMessage &amp; "Error: " &amp; Err.Number &amp; " - " &amp; Err.Description &amp; VbCrLf

WScript.Echo strMessage
WScript.Quit

End Sub</Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
</WriteAction>
</MemberModules>
<Composition>
<Node ID="WA"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.CommandOutput</OutputType>
<InputType>System!System.BaseData</InputType>
</WriteActionModuleType>