'*************************************************************************
' ScriptName: Microsoft.Windows.Server.DNS.ControlZone.WA
'
' Purpose: DNS Server DNS Control Zone Write Action
'
' File: Microsoft.Windows.Server.DNS.ControlZone.WA.vbs
'*************************************************************************
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.")
strMessage = ""
strMessage = strMessage & SCRIPT_NAME & " completed successfully." & VbCrLf
strMessage = strMessage & "Zone: " & strZone & VbCrLf
strMessage = strMessage & "Command: " & strCommand & VbCrLf
WScript.Echo strMessage
Next
Sub ThrowScriptErrorAndAbort(strMessageArg)
Dim strMessage
strMessage = ""
strMessage = strMessage & SCRIPT_NAME & " completed with an error." & VbCrLf
strMessage = strMessage & strMessageArg & VbCrLf
strMessage = strMessage & "Server: " & strServer & VbCrLf
strMessage = strMessage & "Zone: " & strZone & VbCrLf
strMessage = strMessage & "Command: " & strCommand & VbCrLf
If Err <> 0 Then strMessage = strMessage & "Error: " & Err.Number & " - " & Err.Description & VbCrLf