question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proxy Authentication using logged on network credentials, works fine in Windows PowerShell

See original GitHub issue

Steps to reproduce

[System.Net.WebRequest]::DefaultWebProxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials

(Invoke-WebRequest -Uri 'https://google.com').StatusCode

Expected behavior

200

Actual behavior

Error message being thrown from network proxy

Authentication Required
You must be authenticated to access this URL.

Environment data

Name                           Value
----                           -----
PSVersion                      7.0.0-preview.3
PSEdition                      Core
GitCommitId                    7.0.0-preview.3
OS                             Microsoft Windows 10.0.17763
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

This works fine on the same machine using Windows PowerShell but doesn’t work in PowerShell 6 or above.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:10

github_iconTop GitHub Comments

5reactions
mikes-ghcommented, Jan 29, 2021

@gabrielmccoll I tried with 7.1.1

PS C:\Users\mikes> [System.Net.WebRequest]::DefaultWebProxy.Credentials =[System.Net.CredentialCache]::DefaultNetworkCredentials
PS C:\Users\mikes>
PS C:\Users\mikes> (Invoke-WebRequest -Uri 'https://google.com').StatusCode
200

It now works for me 🎉

1reaction
iSazonovcommented, Jan 15, 2021

It comes from .Net.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Access web using Powershell and Proxy
I can't seem to get access to a webpage using Powershell. I keep getting a "(407) Proxy Authentication Required". I've tried many things....
Read more >
Using PowerShell Behind a Proxy Server
In this article, we'll show you how to configure PowerShell to access the Web through a proxy server with authentication.
Read more >
Bypass proxy for all web requests in Powershell Core
The following command will use the credentials of your domain account under which you're currently logged in to Windows: [System.Net.
Read more >
Troubleshoot Azure AD connectivity issues
Verify proxy connectivity. To check whether the Azure AD Connect server is connecting to the proxy and the internet, use some PowerShell cmdlets ......
Read more >
Troubleshooting Web Application Proxy
All errors are presented to the PowerShell user using standard PowerShell error ... Verify that AD FS is reachable and working properly.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found