'****************************************************************************************** '*** Name: asf.vbs '*** Purpose: To get or set ASF Configuration on a ASF Client. '*** Usage: cscript.exe asf.vbs [/target:] [/user:] [/password:] '*** Usage: [/enable:true|false] [/destinationip:] [/ping:true|false] '*** Usage: [/pinginterval:] [/heartbeat:true|false] [/heartbeatinterval:] '*** Usage: [/snmpcommunity:] [/retrycount:] [/retryinterval:] '*** '*** The /target switch is used to identify the target machine of the script. If /target is not '*** specified, the script is applied to the local computer. If /target is specified, the script '*** is applied remotely to the target machine. '*** The /user switch is used to specify a user account for the remote connection '*** '*** The /password switch is used to specify the password for the user account specified by the '*** /user switch. Note: The /password switch must be used with the /user switch. 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 community must be set. '*** '*** The /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 interval specified in '*** pinginterval. The /ping:false disables the ASF from pinging the destination IP. '*** '*** The /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 destination IP at '*** the interval specified in heartbeatinterval. The /heartbeat:false disables the ASF from sending '*** heartbeat PETs to the destination IP. '*** '*** The /heartbeatinterval: switch sets the interval between sending PETs to '*** the destination IP. '*** '*** The /snmpcommunity: switch sets the snmp community for the PETs. '*** '*** The /retrycount: switch tells the ASF how many times to resend the PETs to the '*** destination IP address. '*** '*** The /retryinterval: switch sets the interval between resending 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 always 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 machine '*** ---------- '*** cscript.exe asf.vbs '*** '*** Example 2 This retrieves the current ASF configuration from a target machine named "frank" '*** by using the /target:frank, /user:steven, and /password:foo switches '*** ---------- '*** cscript.exe asf.vbs /target:frank /user:steven /password:foo '*** '*** Example 3 This enables ASF on the local machine to send PETs, in the public community, '*** to ip address 10.1.1.5 by using the /enable:true, the /destinationip:10.1.1.5, '*** and the /snmpcommunity:public switches. '*** ---------- '*** cscript.exe asf.vbs /enable:true /destinationip:10.1.1.5 /snmpcommunity:public '*** '*** 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:frank, /user:steven, '*** /password:foo, /enable:true, /destinationip:10.1.1.5, and /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 therewith. '*** 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:" then 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, strUserName, 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) & strKeyValue & 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.ReasonForSafeMode else WScript.Echo "ASF Alerting Enabled: " & objInstance.Enable WScript.Echo "ASF Trap Destination Address: " & objInstance.DestinationAddress WScript.Echo "ASF SNMP Community: " & objInstance.SNMP_Community WScript.Echo "ASF Heartbeat Enabled: " & objInstance.EnablePresenceHeartbeats WScript.Echo "ASF Heartbeat Interval: " & objInstance.PresenceHeartbeatInterval WScript.Echo "ASF Ping Destination Enable: " & objInstance.PingAlertDestination WScript.Echo "ASF Ping Interval: " & objInstance.AlertDestinationPingInterval WScript.Echo "ASF Retry Count: " & objInstance.RetryCount WScript.Echo "ASF Retry Interval: " & objInstance.RetryInterval 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:]" & VBCRLF & _ " [/user: [/password:]]" & VBCRLF & _ " [/enable:true|false]" & VBCRLF & _ " [/destinationip:]" & VBCRLF & _ " [/ping:true|false]" & VBCRLF & _ " [/pinginterval:]" & VBCRLF & _ " [/heartbeat:true|false]" & VBCRLF & _ " [/heartbeatinterval:]" & VBCRLF & _ " [/snmpcommunity:]" & VBCRLF & _ " [/retrycount:]" & VBCRLF & _ " [/retryinterval:]" WScript.Echo strMessage End Sub