locked
Invoke-WebRequest and proxy RRS feed

  • Question

  • I am newbie to Powershell and I am just using a test script to see if I can get to the internet through our proxy server. I am using the following script:

    $secPasswd=ConvertTo-SecureString"password"-AsPlainText-Force


    $myCreds

    =New-ObjectSystem.Management.Automation.PSCredential-ArgumentList"AD\WIR",$secPasswd

    $Site

    ="http://www.computerperformance.co.uk"



    $Test=Invoke-WebRequest-URI$Site-Proxy'http://10.0.77.1'-ProxyCredential$mycreds

    $Test

    .Links |Foreach{$_.href }

    WebRequest : Proxy authorization required. Any help would be appreciated. The username and password are correct.

    Tuesday, August 12, 2014 6:40 PM

Answers

  • Hi Chantilly,

    Please try to provide the port of the proxy server in the parameter "Proxy":

    $secPasswd=ConvertTo-SecureString "password" -AsPlainText -Force
    $myCreds=New-Object System.Management.Automation.PSCredential -ArgumentList "Domain\name",$secPasswd
    $Site="http://www.computerperformance.co.uk"
    $Test=Invoke-WebRequest -URI $Site -Proxy 'http://10.0.77.1:port' -ProxyCredential $mycreds
    $Test.Links 

    In addition, this similar script is for your reference:

    Invoke-WebRequest GetSystemWebProxy()

    If there is anything else regarding this script, please feel free to let me know.

    Best Regards,

    Anna Wang

    • Marked as answer by AnnaWY Monday, August 25, 2014 10:32 AM
    Thursday, August 14, 2014 2:56 AM