Sei sulla pagina 1di 7

'*******************************************************************************

***********
'*** Name: asf.vbs
'*** Purpose: To get or set ASF Configuration on a ASF Client.
'*** Usage: cscript.exe asf.vbs [/target:<systemname>] [/user:<username>] [/pass
word:<password>]
'*** Usage: [/enable:true|false] [/destinationip:<destinationip>] [/ping:true
|false]
'*** Usage: [/pinginterval:<interval>] [/heartbeat:true|false] [/heartbeatint
erval:<interval>]
'*** Usage: [/snmpcommunity:<snmpcommunity>] [/retrycount:<retrycount>] [/ret
ryinterval:<retryinterval>]
'***
'*** The /target switch is used to identify the target machine of the script. I
f /target is not
'*** specified, the script is applied to the local computer. If /target is spec
ified, the script
'*** is applied remotely to the target machine.
'*** The /user switch is used to specify a user account for the remote connectio
n
'***
'*** The /password switch is used to specify the password for the user account s
pecified by the
'*** /user switch. Note: The /password switch must be used with the /user swit
ch. You cannot specify
'*** a password without specifying a user.
'***
'*** The /enable:true switch turns ASF on. The /enable:false turns ASF off.
'*** Note: In order to successfully enable ASF, the destination IP and snmp com
munity must be set.
'***
'*** The /destinationip:<destinationip> switch tells the ASF what IP address to
send the PETs to.
'***
'*** The /ping:true switch enables the ASF to ping the destination IP at the int
erval specified in
'*** pinginterval. The /ping:false disables the ASF from pinging the destinatio
n IP.
'***
'*** The /pinginterval:<pinginterval> switch sets the interval between pings of
the destination IP.
'***
'*** The /heartbeat:true switch enables the ASF to send a heartbeat PET to the d
estination IP at
'*** the interval specified in heartbeatinterval. The /heartbeat:false disables
the ASF from sending
'*** heartbeat PETs to the destination IP.
'***
'*** The /heartbeatinterval:<heartbeatinterval> switch sets the interval between
sending PETs to
'*** the destination IP.
'***
'*** The /snmpcommunity:<snmpcommunity> switch sets the snmp community for the P
ETs.
'***
'*** The /retrycount:<retrycount> switch tells the ASF how many times to resend
the PETs to the
'*** destination IP address.
'***
'*** The /retryinterval:<retryinterval> switch sets the interval between resendi
ng the PETs to
'*** the destination IP.
'***
'***
'*** You can use any combination of the switches to set the configuration or you
can use no
'*** switches to retrieve the current configuration. The /target switch is alwa
ys used to identify
'*** the target machine to apply the script to.
'***
'***
'*** Examples of some typical uses of the script are below
'*** ===========================================================================
==========
'*** Example 1 This retrieves the current ASF configuration from the local mach
ine
'*** ----------
'*** cscript.exe asf.vbs
'***
'*** Example 2 This retrieves the current ASF configuration from a target machi
ne named "frank"
'*** by using the /target:frank, /user:steven, and /password:foo swit
ches
'*** ----------
'*** cscript.exe asf.vbs /target:frank /user:steven /password:foo
'***
'*** Example 3 This enables ASF on the local machine to send PETs, in the publi
c community,
'*** to ip address 10.1.1.5 by using the /enable:true, the /d
estinationip:10.1.1.5,
'*** and the /snmpcommunity:public switches.
'*** ----------
'*** cscript.exe asf.vbs /enable:true /destinationip:10.1.1.5 /snmpcommunity:pub
lic
'***
'*** Example 4 This enables ASF on a target machine named "frank" to send PETs,
in the public
'*** community, to ip address 10.1.1.5 by using the /target:f
rank, /user:steven,
'*** /password:foo, /enable:true, /destinationip:10.1.1.5, an
d /snmpcommunity:public switches.
'*** ----------
'*** cscript.exe asf.vbs /target:frank /user:steven /password:foo /enable:true /
destinationip:10.1.1.5 /snmpcommunity:public
'***
'*** ===========================================================================
===========
'*** The sample script is provided as an example only, and has not been tested,
nor is
'*** warranted in any way by Dell; Dell disclaims any liability in connection th
erewith.
'*** Dell provides no technical support with regard to such scripting. For more
information
'*** on WMI scripting, refer to applicable Microsoft documentation.€
'***
'***
'*******************************************************************************
***********
Option Explicit

'*** Declare variables


Dim strNameSpace
Dim strClassName
Dim strKeyValue
Dim objInstance
Dim ObjServices
Dim ObjLocator
Dim ObjWbemObjectSet
Dim strComputerName
Dim strUserName
Dim strPassword
Dim boolGet
Dim strPropEnableValue
Dim strPropDestinationIPValue
Dim strPropPingEnableValue
Dim strPropPingIntervalValue
Dim strPropHBEnableValue
Dim strPropHBIntervalValue
Dim strPropSNMPCommunityValue
Dim strPropRetryCountValue
Dim strPropRetryIntervalValue

'*** Check that the right executable was used to run the script
'*** and that all parameters were passed
If (LCase(Right(WScript.FullName, 11)) = "wscript.exe" ) Then
Call Usage()
WScript.Quit
End If
'*** Initialize variables
strNameSpace = "root/cimv2"
strClassName = "IA_ASF_OOBAlertService"
strKeyValue = "Intel ASF OOB Alert Service"
strComputerName = "localhost"
boolGet = TRUE

Dim i
for i = 0 to WScript.Arguments.Count-1
if Left(LCase(WScript.Arguments(i)), 8) = "/target:" then
strComputerName = Mid(WScript.Arguments(i), 9)
elseif Left(LCase(WScript.Arguments(i)), 6) = "/user:" then
strUserName = Mid(WScript.Arguments(i), 7)
elseif Left(LCase(WScript.Arguments(i)), 10) = "/password:" then
if (strUserName <> "") then
strPassword = Mid(WScript.Arguments(i), 11)
else
Call Usage()
WScript.Quit
end if
elseif Left(LCase(WScript.Arguments(i)), 8) = "/enable:" then
boolGet = FALSE
if LCase(Mid(WScript.Arguments(i), 9)) = "true" then
strPropEnableValue = 1
elseif LCase(Mid(WScript.Arguments(i), 9)) = "false" then
strPropEnableValue = 0
else
Call Usage()
Wscript.Quit
end if
elseif Left(LCase(WScript.Arguments(i)), 15) = "/destinationip:" then
boolGet = FALSE
strPropDestinationIPValue = Mid(WScript.Arguments(i), 16)
elseif Left(LCase(WScript.Arguments(i)), 6) = "/ping:" then
boolGet = FALSE
if LCase(Mid(WScript.Arguments(i), 7)) = "true" then
strPropPingEnableValue = 1
elseif LCase(Mid(WScript.Arguments(i), 7)) = "false" then
strPropPingEnableValue = 0
else
Call Usage()
Wscript.Quit
end if
elseif Left(LCase(WScript.Arguments(i)), 14) = "/pinginterval:" then
boolGet = FALSE
strPropPingIntervalValue = Mid(WScript.Arguments(i), 15)
elseif Left(LCase(WScript.Arguments(i)), 11) = "/heartbeat:" then
boolGet = FALSE
if LCase(Mid(WScript.Arguments(i), 12)) = "true" then
strPropHBEnableValue = 1
elseif LCase(Mid(WScript.Arguments(i), 12)) = "false" then
strPropHBEnableValue = 0
else
Call Usage()
Wscript.Quit
end if
elseif Left(LCase(WScript.Arguments(i)), 19) = "/heartbeatinterval:" the
n
boolGet = FALSE
strPropHBIntervalValue = Mid(WScript.Arguments(i), 20)
elseif Left(LCase(WScript.Arguments(i)), 15) = "/snmpcommunity:" then
boolGet = FALSE
strPropSnmpCommunityValue = Mid(WScript.Arguments(i), 16)
elseif Left(LCase(WScript.Arguments(i)), 12) = "/retrycount:" then
boolGet = FALSE
strPropRetryCountValue = Mid(WScript.Arguments(i), 13)
elseif Left(LCase(WScript.Arguments(i)), 15) = "/retryinterval:" then
boolGet = FALSE
strPropRetryIntervalValue= Mid(WScript.Arguments(i), 16)
else
Call Usage()
Wscript.Quit
end if
next

'*** Retrieve the instance of IA_ASF_OOBAlertService class (there should only be


1 instance).
Set ObjLocator = CreateObject("Wbemscripting.SWbemLocator")
Set ObjServices = ObjLocator.ConnectServer( strComputerName, strNameSpace, strUs
erName, strPassword)
If (IsObject(ObjServices) = FALSE) Then
WScript.Echo Err.Description
WScript.Quit
End If
ObjServices.Security_.ImpersonationLevel = 3 'impersonate
ObjServices.Security_.AuthenticationLevel = 4 'packet
Set ObjWbemObjectSet = ObjServices.InstancesOf(strClassName)
Set ObjInstance = objWbemObjectSet.Item(strClassName & ".Name=" & Chr(34) & strK
eyValue & Chr(34))
If (IsObject(ObjInstance) = FALSE) Then
WScript.Echo Err.Description
WScript.Quit
End If
if (boolGet = TRUE) then
Call GetASF()
WScript.Quit
end if

if strPropEnableValue <> "" then


objInstance.Enable = strPropEnableValue
WScript.Echo "setting ASF Enable to " & strPropEnableValue
end if
if strPropDestinationIPValue <> "" then
objInstance.DestinationAddress = strPropDestinationIPValue
WScript.Echo "setting Destination IP to " & strPropDestinationIPValue
end if
if strPropPingEnableValue <> "" then
objInstance.PingAlertDestination = strPropPingEnableValue
WScript.Echo "setting Ping Enable to " & strPropPingEnableValue
end if
if strPropPingIntervalValue <> "" then
objInstance.AlertDestinationPingInterval = strPropPingIntervalValue
WScript.Echo "setting Ping Interval to " & strPropPingIntervalValue
end if
if strPropHBEnableValue <> "" then
objInstance.EnablePresenceHeartbeats = strPropHBEnableValue
WScript.Echo "setting Heartbeat enable to " & strPropHBEnableValue
end if
if strPropHBIntervalValue <> "" then
objInstance.PresenceHeartbeatInterval = strPropHBIntervalValue
WScript.Echo "setting Heartbeat interval to " & strPropHBIntervalValue
end if
if strPropSNMPCommunityValue <> "" then
objInstance.SNMP_Community = strPropSNMPCommunityValue
WScript.Echo "setting SNMP Community to " & strPropSNMPCommunityValue
end if
if strPropRetryCountValue <> "" then
objInstance.RetryCount = strPropRetryCountValue
WScript.Echo "setting Retry Count to " & strPropRetryCountValue
end if
if strPropRetryIntervalValue <> "" then
objInstance.RetryInterval = strPropRetryIntervalValue
WScript.Echo "setting Retry Interval to " & strPropRetryIntervalValue
end if

objInstance.Put_
'*** If any errors occurred, let the user know
If Err.Number <> 0 Then
WScript.Echo "Setting ASF Enable/Disable failed."
End If
Call GetASF()
Sub GetASF()
WScript.Echo VBCRLF & VBCRLF
If objInstance.Enable = true Then
if objInstance.SafeMode = true then
WScript.Echo "ASF Agent is in SAFE MODE! " & objInstance.ReasonF
orSafeMode
else
WScript.Echo "ASF Alerting Enabled: " & objInstance.Enab
le
WScript.Echo "ASF Trap Destination Address: " & objInstance.Dest
inationAddress
WScript.Echo "ASF SNMP Community: " & objInstance.SNMP
_Community
WScript.Echo "ASF Heartbeat Enabled: " & objInstance.Enab
lePresenceHeartbeats
WScript.Echo "ASF Heartbeat Interval: " & objInstance.Pres
enceHeartbeatInterval
WScript.Echo "ASF Ping Destination Enable: " & objInstance.Ping
AlertDestination
WScript.Echo "ASF Ping Interval: " & objInstance.Aler
tDestinationPingInterval
WScript.Echo "ASF Retry Count: " & objInstance.Retr
yCount
WScript.Echo "ASF Retry Interval: " & objInstance.Retr
yInterval
End if
Else
WScript.Echo "ASF Alerting Disabled"
End If
'*** If any errors occurred, let the user know
If Err.Number <> 0 Then
WScript.Echo "Setting ASF Enable/Disable failed."
End If
End Sub

'*** Sub used to display the correct usage of the script


Sub Usage()
Dim strMessage
strMessage = "incorrect syntax. You should run: " & vbCRLF & _
"cscript.exe Asf.vbs [/target:<systemname>]" & VBCRLF & _
" [/user:<username> [/password:<password>]]" & VBCR
LF & _
" [/enable:true|false]" & VBCRLF & _
" [/destinationip:<destinationip>]" & VBCRLF & _
" [/ping:true|false]" & VBCRLF & _
" [/pinginterval:<interval>]" & VBCRLF & _
" [/heartbeat:true|false]" & VBCRLF & _
" [/heartbeatinterval:<interval>]" & VBCRLF & _
" [/snmpcommunity:<snmpcommunity>]" & VBCRLF & _
" [/retrycount:<retrycount>]" & VBCRLF & _
" [/retryinterval:<retryinterval>]"

WScript.Echo strMessage
End Sub

Potrebbero piacerti anche