Skip to content

Commit

Permalink
Merge pull request #1942 from microsoft/dpaul-HcWebProxy
Browse files Browse the repository at this point in the history
Health Checker Web Proxy Update
  • Loading branch information
dpaulson45 authored Jan 18, 2024
2 parents 625ad3e + ddbbb6d commit ed84e0a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: $_"
}
}

Expand Down

0 comments on commit ed84e0a

Please sign in to comment.