powershell, Uncategorized

Powershell : WebRequest Server Not Found

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s