On Error Resume Next
Set objDNSWMI = GetObject("winmgmts:\\" & strServer & "\root\MicrosoftDNS")
If Err <> 0 Then Call ThrowScriptErrorAndAbort("Unable to connect to MicrosoftDNS namespace.")
Set colZones = objDNSWMI.ExecQuery("Select * from MicrosoftDNS_Zone where name = '" & strZone & "'")
If (Err <> 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 <> 0 Then Call ThrowScriptErrorAndAbort("Unable to perform specified action.")
'If we reach this point, assume we have succeeded.
strMessage = SCRIPT_NAME & " completed successfully." & VbCrLf & _
"Zone: " & strZone & VbCrLf & _
"Command: " & strCommand & VbCrLf
WScript.Echo strMessage
Next
Sub ThrowScriptErrorAndAbort(strMessage)
strMessage = SCRIPT_NAME & " completed with an error." & VbCrLf & _
strMessage & VbCrLf & VbCrLf & _
"Server: " & strServer & VbCrLf & _
"Zone: " & strZone & VbCrLf & _
"Command: " & strCommand & VbCrLf
If Err <> 0 Then strMessage = strMessage & "Error: " & Err.Number & " - " & Err.Description & VbCrLf
WScript.Echo strMessage
WScript.Quit
End Sub
'</Script></ScriptBody>
<TimeoutSeconds>30</TimeoutSeconds>
</WriteAction>
</MemberModules>
<Composition>
<Node ID="WA"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.CommandOutput</OutputType>
<InputType>System!System.BaseData</InputType>
</WriteActionModuleType>