Dim strComputer
Dim strCommand
call ParseCommand()
Wscript.Echo ""
Wscript.Echo "MicrosoftNLB_Node"
Wscript.Echo "================="
Wscript.Echo ""
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\MicrosoftNLB")
Set colItems = objWMIService.ExecQuery("Select * from MicrosoftNLB_Node",,48)
For Each objItem in colItems
Wscript.Echo "ComputerName: " & objItem.ComputerName
Wscript.Echo "DedicatedIPAddress: " & objItem.DedicatedIPAddress
Wscript.Echo "HostPriority: " & objItem.HostPriority
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "StatusCode: " & objItem.StatusCode
Wscript.Echo ""
If strCommand = "drainstop" Then
Wscript.Echo "Stopping the node"
ReturnValue = objItem.DrainStop()
bStart = true
Wscript.Echo "Waiting the node to stop..."
Wscript.Echo ""
While(bStart)
Set colItems1 = objWMIService.ExecQuery("Select StatusCode from MicrosoftNLB_Node",,48)
For Each objItem1 in colItems1
Call DisplayReturnValue(objItem1.StatusCode)
if objItem1.StatusCode = "1005" then
bStart = false
end if
Next
WScript.Sleep 1000
Wend
Wscript.Echo ""
Wscript.Echo "Node Stopped"
Wscript.Echo ""
End If
If strCommand = "start" Then
Wscript.Echo "Start the node"
objItem.Start()
End If
Next
sub DisplayReturnValue(ReturnValue)
select case ReturnValue
case 1000
wscript.echo " Success."
case 1001
wscript.echo " Cluster mode is already stopped/started, or traffic handling is already enabled/disabled on specified port."
case 1002
wscript.echo " Cluster mode stop or start operation interrupted connection draining process."
case 1003
wscript.echo " Cluster mode could not be started due to configuration problems on the target host."
case 1004
wscript.echo " Port number not found among port rules."
case 1005
wscript.echo " Cluster mode is stopped on the host."
case 1006
wscript.echo " Cluster is converging."
case 1007
wscript.echo " Cluster or host converged successfully."
case 1008
wscript.echo " Host is converged as default host."
case 1009
wscript.echo " Host is draining after drainstop command."
case else:
wscript.echo " Unknown return (" & ReturnValue & ")."
end select
End Sub
Function ParseCommand()
Dim ArgCount
Dim oArgs
Set oArgs = Wscript.Arguments
ArgCount = 0
if oArgs.Count = 0 then
wscript.echo "No arguments specified."
wscript.echo
call Help()
end if
While ArgCount < oArgs.Count
Select Case LCase(oArgs(ArgCount))
Case "-n"
ArgCount = ArgCount + 1
strComputer=LCase(oArgs(ArgCount))
wscript.echo "Server name : " & strComputer
Case "-c"
ArgCount = ArgCount + 1
strCommand=LCase(oArgs(ArgCount))
wscript.echo "Command : " & strCommand
Case Else:
wscript.echo "Invalid command."
wscript.echo
call Help()
wscript.quit
End Select
ArgCount = ArgCount + 1
Wend
End Function
sub Help()
wscript.echo "Stop/Start Network Load Balancing (NLB) service"
wscript.echo "Syntax:"
wscript.echo
wscript.echo "-n Server name or IP"
wscript.echo "-c command name : drainstop or start"
wscript.echo
wscript.echo "Examples:"
wscript.echo
wscript.echo "myscript.vbs -n ""MyServerName"" -c ""drainstop"""
wscript.quit
End Sub
Lien vers le fichier : cliquez ici