Windows Update Agent Proxy Configuration Detection

Microsoft.SystemCenter.Essentials.WUAgent.ProxyConfigurationDetection (UnitMonitor)

Checks to determine if the Windows Update Agent is unable to connect to the Essentials server due to an automatically detected proxy server.

Knowledge Base article:

Summary

The Windows Update Agent is unable to communicate with the Essentials server due to a proxy configuration issue.

Causes

A proxy server on the network is being automatically used by the Windows Update Agent.  The proxy server is not configured to allow FQDN traffic to the Essentials server.

Resolutions

Add a rule or configuration to your proxy server to route traffic destined for the FQDN of the Essentials server back internally to the Essentials server.

Element properties:

TargetMicrosoft.SystemCenter.Essentials.WUAgent
Parent MonitorSystem.Health.AvailabilityState
CategoryAvailabilityHealth
EnabledTrue
Alert GenerateFalse
Alert Auto ResolveTrue
Monitor TypeMicrosoft.Windows.TimedScript.TwoStateMonitorType
RemotableFalse
AccessibilityInternal
RunAsDefault

Source Code:

<UnitMonitor ID="Microsoft.SystemCenter.Essentials.WUAgent.ProxyConfigurationDetection" Accessibility="Internal" Enabled="onEssentialMonitoring" Target="Microsoft.SystemCenter.Essentials.WUAgent" ParentMonitorID="Health!System.Health.AvailabilityState" Remotable="false" Priority="Normal" TypeID="Windows!Microsoft.Windows.TimedScript.TwoStateMonitorType" ConfirmDelivery="false">
<Category>AvailabilityHealth</Category>
<OperationalStates>
<OperationalState ID="Success" MonitorTypeStateID="Success" HealthState="Success"/>
<OperationalState ID="Error" MonitorTypeStateID="Error" HealthState="Warning"/>
</OperationalStates>
<Configuration>
<IntervalSeconds>3600</IntervalSeconds>
<SyncTime/>
<ScriptName>ProxyConfigurationDetection.vbs</ScriptName>
<Arguments/>
<ScriptBody><Script>
'*************************************************************************
' Script Name - ProxyConfigurationDetection.vbs
'
' Purpose - Checks to see if WU Agent is not able to connect to Essentials Server
' due to Proxy issue
'
' Assumptions - Script is run as a runtime task
'
' Parameters - ManagementGroupName
'
' (c) Copyright 2006, Microsoft Corporation, All Rights Reserved
' Proprietary and confidential to Microsoft Corporation
'*************************************************************************

OPTION EXPLICIT
SetLocale("en-us")

Const SCRIPT_NAME = "ProxyConfigurationDetection"

Const EVENT_TYPE_WARNING = 2
Const EVENT_TYPE_INFORMATION = 4

Const EVENT_ID_SCRIPT_ERROR = 1000
Const EVENT_ID_SUCCESS = 99

Dim oAPI, objArgs, oBag
Dim objWebProxy, objSession, objUpdateSearcher, objSearchResults

'Create OpsMgr object
Set oAPI = CreateObject("Mom.ScriptAPI")

' Create a property bag
Set oBag= oAPI.CreatePropertyBag()

set objWebProxy = CreateObject("Microsoft.Update.WebProxy")

If IsNull(objwebProxy) OR IsEmpty(objwebProxy) Then
ScriptError "Unable to create Microsoft.Update.WebProxy object. " &amp; GetErrorString(Err)
Call oBag.AddValue("ProxyConfig", "Bad")
Call oAPI.Return(oBag)
Quit()
End If

Set objSession = CreateObject("Microsoft.Update.Session")

If IsNull(objSession) OR IsEmpty(objSession) Then
ScriptError "Unable to create Microsoft.Update.Session object. " &amp; GetErrorString(Err)
Call oBag.AddValue("ProxyConfig", "Bad")
Call oAPI.Return(oBag)
Quit()
End If

' Set the WebProxy of session
objSession.WebProxy = objWebProxy

' Create searcher object
set objUpdateSearcher = objSession.CreateUpdateSearcher()
'wscript.echo "Checking for connection..."

Err.Clear

On Error Resume Next

set objSearchResults = objUpdateSearcher.Search("IsInstalled = 0 and IsHidden = 0")

'wscript.echo Err.number

' HEX Error number 80244021 is Bad Gateway (HTTP 502 Error)
' http://technet.microsoft.com/en-us/library/cc720442(WS.10).aspx
If Hex(Err.number) = "80244021" Then
On Error Goto 0

' If there is bad gateway, set auto-detect to false and try again
objWebProxy.AutoDetect = false

Err.Clear
On Error Resume Next
set objSearchResults = objUpdateSearcher.Search("IsInstalled = 0 and IsHidden = 0")

' If it succeeds then we know that WUAgent is not able to connect because of proxy
If (Hex(Err.number) = 0) Then
'wscript.echo "BAD"
Call oBag.AddValue("ProxyConfig", "Bad")
Call oAPI.Return(oBag)
Quit()
End If
end if

'If the error is not bad gateway, then we are good
'wscript.echo "GOOD"
Call oBag.AddValue("ProxyConfig", "Good")
Call oAPI.Return(oBag)
Quit()

'******************************************************************************
Sub ScriptError(strError)
'
' Purpose: Records a script error.
'
' Parameters: strError, the description of the error to record
''******************************************************************************

CreateEvent EVENT_ID_SCRIPT_ERROR, EVENT_TYPE_WARNING, "The script '" &amp; SCRIPT_NAME &amp; "' failed while " &amp; strError
End Sub

'******************************************************************************
Function GetErrorString(oErr)
'
' Purpose: Attempts to find the description for an error if an error with
' no description is passed in.
'
' Parameters: oErr, the error object
'
' Return: String, the description for the error. (Includes the error code.)
'******************************************************************************

Dim lErr, strErr
lErr = oErr
strErr = oErr.Description

On Error Resume Next
If 0 &gt;= Len(strErr) Then
' If we don't have an error description, then check to see if the error
' is a 0x8007xxxx error. If it is, then look it up.
Const ErrorMask = &amp;HFFFF0000
Const HiWord8007 = &amp;H80070000
Const LoWordMask = 65535 ' This is equivalent to 0x0000FFFF

If (lErr And ErrorMask) = HiWord8007 Then
' Attempt to use 'net helpmsg' to get a description for the error.
Dim oShell
Set oShell = CreateObject("WScript.Shell")
If Err = 0 Then
Dim oExec
Set oExec = oShell.Exec("net helpmsg " &amp; (lErr And LoWordMask))

Dim strMessage, i
Do
strMessage = oExec.stdout.ReadLine()
i = i + 1
Loop While (Len(strMessage) = 0) And (i &lt; 5)

strErr = strMessage
End If
End If
End If

GetErrorString = vbCrLf &amp; "The error returned was: '" &amp; strErr &amp; "' (0x" &amp; Hex(lErr) &amp; ")"
End Function

'******************************************************************************
Sub CreateEvent(lngEventID, lngEventType, strMessage)
'
' Purpose: To create a MOM event
'
' Arguments:lngEventID, the event ID
' lngEventType, the event type (see values at top of file)
' strMessage, the message text for the event
'******************************************************************************
oAPI.LogScriptEvent "ProxyConfigurationDetection", lngEventID, lngEventType, strMessage
End Sub

'*************************************************************************
Function Quit()

WScript.Quit()

End Function
'****************************************************************************
</Script></ScriptBody>
<SecureInput/>
<TimeoutSeconds>300</TimeoutSeconds>
<ErrorExpression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='ProxyConfig']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">Bad</Value>
</ValueExpression>
</SimpleExpression>
</ErrorExpression>
<SuccessExpression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='ProxyConfig']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">Good</Value>
</ValueExpression>
</SimpleExpression>
</SuccessExpression>
</Configuration>
</UnitMonitor>