Are there any examples of shutting down a computer via the DRA ADSI provider? (NETIQKB41250)

  • 7741250
  • 02-Feb-2007
  • 19-Jun-2007


Are there any examples of shutting down a computer via the DRA ADSI provider?

Directory and Resource Administrator 6.x

Directory and Resource Administrator 7.x


Below is a sample of how to shutdown a computer via the DRA ADSI provider.  Please note that questions regarding scripting and the DRA ADSI Provider fall outside the normal scope of NetIQ Technical Support. As such the following sample is not supported.

' ShutDownComputer.vbs
' This script uses the DRA ScriptSubmit method of the EAServe
' object to issue a shutdown request to a computer.
' The following named parameters need to be specified.  It is
' recommended that you specify all the parameters.  This script
' has executed successfully when it runs on a DRA server where the
' DRA server is the name of the server where the script executes.
'   /server:DRA server where the request will be issued
'   /computer:"distinguished AD name of the computer to shutdown"
'   /Restart:True or False
'   /ShutDownDelay:minutes
'   /ShutDownMsg:"shutdown message"
' Example:
' cscript ShutdownComputer.vbs /server:x1010w2k /computer:"cn=cabc,OU=Accounting,OU=Amsterdam,OU=Keystone Steel Company,OU=NetIQ DRA-ExA EvalGuide,DC=X1010W2Kdom,DC=local" /restart:false /shutdowndelay:10 /shutdownmsg:"Shutting down in 10 minutes!"

'Set objArgs = WScript.Arguments
'For I = 0 to objArgs.Count - 1
'   WScript.Echo objArgs(I)

Set argsNamed = WScript.Arguments.Named
'Set argsUnnamed = WScript.Arguments.Unnamed

WScript.Echo "There are " & argsNamed.Count & " named arguments."
'WScript.Echo "There are " & argsUnnamed.Count & " unnamed arguments."

'WScript.Echo WScript.Arguments.Named.Item("server")
'WScript.Echo WScript.Arguments.Named.Item("computer")
'WScript.Echo WScript.Arguments.Named.Item("restart")
'WScript.Echo WScript.Arguments.Named.Item("shutdownmsg")
'WScript.Echo WScript.Arguments.Named.Item("shutdowndelay")

sServer = WScript.Arguments.Named.Item("server")
sComputer = WScript.Arguments.Named.Item("computer")
bRestart = CBool(WScript.Arguments.Named.Item("restart"))
sShutDownMsg = WScript.Arguments.Named.Item("shutdownmsg")
lShutDownDelay = CLng(WScript.Arguments.Named.Item("shutdowndelay"))


WScript.Echo "sServer: " & sServer
WScript.Echo "sComputer: " & sComputer
WScript.Echo "bRestart: " & bRestart
WScript.Echo "sShutDownMsg: " & sShutDownMsg
WScript.Echo "lShutDownDelay: " & lShutDownDelay


' Get an instance of a Connector
Set gWebDcom = CreateObject("McsWebDcom.Connector.1")
' Get an instance of an EAServe object
Set gEaServerObject = gWebDcom.GetEaServer(sServer)
Set VarSetIn = CreateObject("NetIQDRAVarSet.VarSet.1")
Set VarSetOut = CreateObject("NetIQDRAVarSet.VarSet.1")

VarSetIn.Put "Client.Version.Build", 0
VarSetIn.Put "Client.Version.Major", 7
VarSetIn.Put "Client.Version.Minor", 0
VarSetIn.Put "Client.Version.Release", &HA1&

VarSetIn.Put "Computer", "OnePoint://" & sComputer 'CN=Cabc,OU=Accounting,OU=Amsterdam,OU=Keystone Steel Company,OU=NetIQ DRA-ExA EvalGuide,DC=X1010W2Kdom,DC=local"
VarSetIn.Put "OperationName", "ComputerShutdown"
VarSetIn.Put "Restart", CLng(bRestart)
VarSetIn.Put "ShutDownDelay", lShutDownDelay * 60 ' delay is specified in seconds
VarSetIn.Put "ShutDownMsg", sShutDownMsg

On Error Resume Next
' Issue the ScriptSubmit meth.
od on the EaServe object
Set VarSetOut = gEaServerObject.ScriptSubmit(VarSetIn)

If Err.Number <> 0 Then
 WScript.Echo "Error: 0x" & Hex(Err.Number) & " Err.Description: " & Err.Description
 WScript.Echo "Shutdown request issued!"
End If

' Errors and warnings reported in the VarSet

lErrors = 0
lErrors = VarSetOut.Get("Errors.NumErrors")
WScript.Echo ""
WScript.Echo "Error count:   " & lErrors
If lErrors > 0 Then
   WScript.Echo ""
   WScript.Echo "Consult error code files included with the DRA SDK to interpret the following error."
   WScript.Echo "Last Error:    0x" & Hex(VarSetOut.Get("Errors.LastError"))
End If

lWarnings = 0
lWarnings = VarSetOut.Get("Warnings.NumWarnings")
WScript.Echo ""
WScript.Echo "Warning count: " & lWarnings
If lWarnings > 0 Then
   WScript.Echo ""
   WScript.Echo "Consult error code files included with the DRA SDK to interpret the following warning."
   WScript.Echo "Last Warning:    0x" & Hex(VarSetOut.Get("Warnings.LastWarning"))
End If

Set VarSetOut = Nothing
Set VarSetIn = Nothing
Set gEaServerObject = Nothing
Set gWebDcom = Nothing



Additional Information

Formerly known as NETIQKB41250