Powershell – Unable to access internet when using admin credentials on Windows 10

powershellwindows 10

Our company policy dictates that users must have admin accounts separately from their usual user accounts. We can call them CONTOSO\johndoe and CONTOSO\a-johndoe. The computer is running Windows 10 Enterprise (version 1607) with PowerShell version 5.1.14393.

For testing purposes I'll open two PowerShell windows next to each other, the first just by clicking the PowerShell shortcut and a second one by right-clicking the shortcut, selecting "Run as administrator" and entering CONTOSO\a-johndoe when prompted for credentials.

Now on the normal PS window if I enter

Invoke-WebRequest -Uri www.google.com

it instantly returns

StatusCode        : 200
StatusDescription : OK

as it should. On the admin PS window it returns the following after around 30 seconds:

Invoke-WebRequest: Unable to connect to the remote server

I'm unable to determine how the admin-elevated PS is unable to access the internet. So far I've discovered the following:

  1. I'm directly connected to internet, no proxies whatsoever in between
  2. netsh winhttp show proxy shows "Direct access (no proxy server)" on both PS windows
  3. I've found no user-targeted GPOs that would cause this
  4. I tried creating a local admin account (to bypass possible GPOs) but the result was the same

Any ideas what I might've missed or what to test and how?

Best Answer

We're using a web proxy that requires authentication, and I find I have the same behaviour in Windows 10.

I have found this to be a workaround, in an elevated PowerShell window:

$req = [System.Net.HttpWebRequest]::Create("https://www.google.com") 
$req.Proxy = [System.Net.WebRequest]::DefaultWebProxy 
$req.Proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials 

After this, I find that other web requests authenticate correctly.