Tuesday, September 17, 2019

Power shell to access Internet behind a proxy server with authentication

  • $Creds=Get-Credential
  •  $proxy = New-Object System.Net.WebProxy
  • $proxy.Address = [uri]"http://xxx.xxx.xxx.xxx:xx"
  • $proxy.Credentials = $Creds
  • [System.Net.WebRequest]::DefaultWebProxy = $proxy
  • Invoke-WebRequest -Uri "https://google.com" -UseBasicParsing

Useful links to refer.
  1. http://woshub.com/using-powershell-behind-a-proxy/
  2. https://stackoverflow.com/questions/38005341/the-response-content-cannot-be-parsed-because-the-internet-explorer-engine-is-no