So at work we use a bit of PowerShell here and there to do various things. We also use PowerShell remoting, where we run the same bit of code on a potential list of remote targets.
One of the things we use a lot is a notification system where it will attempt to use this code or code
Invoke-RestMethod -Uri "$env:mattermost_uri" -Method Post -Body $json -ContentType "application/json"
But occasionally this would fail on some of our target VMs, where I would see a “Unable to connect to remote server“.
Turns out there is a default proxy at play which can be disabled like this
[System.Net.HttpWebRequest]::DefaultWebProxy = New-Object System.Net.WebProxy
After that is was all good for me