diff --git a/Diagnostics/HealthChecker/Analyzer/Invoke-AnalyzerOsInformation.ps1 b/Diagnostics/HealthChecker/Analyzer/Invoke-AnalyzerOsInformation.ps1 index e49fd53613..2b9f3680d0 100644 --- a/Diagnostics/HealthChecker/Analyzer/Invoke-AnalyzerOsInformation.ps1 +++ b/Diagnostics/HealthChecker/Analyzer/Invoke-AnalyzerOsInformation.ps1 @@ -332,7 +332,9 @@ function Invoke-AnalyzerOsInformation { if (($osInformation.NetworkInformation.HttpProxy.ProxyAddress -ne "None") -and ($exchangeInformation.GetExchangeServer.IsEdgeServer -eq $false) -and - ($osInformation.NetworkInformation.HttpProxy.ProxyAddress -ne $exchangeInformation.GetExchangeServer.InternetWebProxy.Authority)) { + ($null -ne $exchangeInformation.GetExchangeServer.InternetWebProxy) -and + ($osInformation.NetworkInformation.HttpProxy.ProxyAddress -ne + "$($exchangeInformation.GetExchangeServer.InternetWebProxy.Host):$($exchangeInformation.GetExchangeServer.InternetWebProxy.Port)")) { $params = $baseParams + @{ Details = "Error: Exchange Internet Web Proxy doesn't match OS Web Proxy." DisplayWriteType = "Red" diff --git a/Diagnostics/HealthChecker/DataCollection/ServerInformation/Get-HttpProxySetting.ps1 b/Diagnostics/HealthChecker/DataCollection/ServerInformation/Get-HttpProxySetting.ps1 index a6be0ee705..02cabbae95 100644 --- a/Diagnostics/HealthChecker/DataCollection/ServerInformation/Get-HttpProxySetting.ps1 +++ b/Diagnostics/HealthChecker/DataCollection/ServerInformation/Get-HttpProxySetting.ps1 @@ -15,25 +15,28 @@ function Get-HttpProxySetting { [Parameter(Mandatory = $true)][string]$RegistryLocation ) $connections = Get-ItemProperty -Path $RegistryLocation + $byteLength = 4 + $proxyStartLocation = 16 + $proxyLength = 0 $proxyAddress = [string]::Empty $byPassList = [string]::Empty if (($null -ne $connections) -and ($Connections | Get-Member).Name -contains "WinHttpSettings") { - $onProxy = $true + try { + $bytes = $Connections.WinHttpSettings + $proxyLength = [System.BitConverter]::ToInt32($bytes, $proxyStartLocation - $byteLength) - foreach ($Byte in $Connections.WinHttpSettings) { - if ($onProxy -and - $Byte -ge 42) { - $proxyAddress += [CHAR]$Byte - } elseif (-not $onProxy -and - $Byte -ge 42) { - $byPassList += [CHAR]$Byte - } elseif (-not ([string]::IsNullOrEmpty($proxyAddress)) -and - $onProxy -and - $Byte -eq 0) { - $onProxy = $false + if ($proxyLength -gt 0) { + $proxyAddress = [System.Text.Encoding]::UTF8.GetString($bytes, $proxyStartLocation, $proxyLength) + $byPassListLength = [System.BitConverter]::ToInt32($bytes, $proxyStartLocation + $proxyLength) + + if ($byPassListLength -gt 0) { + $byPassList = [System.Text.Encoding]::UTF8.GetString($bytes, $byteLength + $proxyStartLocation + $proxyLength, $byPassListLength) + } } + } catch { + Write-Verbose "Failed to properly get HTTP Proxy information. Inner Exception: $_" } }