microsoft / CSS-Exchange

Exchange Server support tools and scripts
MIT License
1.22k stars 340 forks source link

[Issue] Confirm-ProxyServer does not work on Powershell 7 #2065

Open bill-long opened 5 months ago

bill-long commented 5 months ago

Describe the issue

The Confirm-ProxyServer shared function always fails on PowerShell 7. Run any script with -Verbose and observe:

Calling Confirm-ProxyServer
Proxy server configuration detected
Unable to check for proxy server configuration

On PowerShell 7, this line throws, so we always end up in the catch:

image

GetSystemWebProxy() is deprecated and there is a new way to do this: https://github.com/dotnet/runtime/issues/24756#issuecomment-519618435

[System.Net.Http.HttpClient]::DefaultProxy.GetProxy("foo")

However, that doesn't work in Windows PowerShell.

Not clear if we should fix this or just let it continue to work this way. In PS7 we will never try to use a proxy. This apparently didn't cause an issue for customers running CVE-2023-23397.ps1. I know we had some using PS7 when running against Exchange Online.