none
PowerShell 4.0 ISE doesn't use the system proxy settings RRS feed

  • Question

  • I can retrieve the contents of a URL using something like 'iwr http://www.adobe.com' in the command-line PowerShell host.

    This takes into account the proxy settings in Control Panel / Internet Options.

    If I attempt the exact same thing in the PowerShell ISE, I get:

    iwr : The remote name could not be resolved: 'www.adobe.com'

    This works only if I add the -Proxy and -ProxyUseDefaultCredentials options.

    How comes?

    How do I fix this?

    • Moved by Bill_Stewart Saturday, February 14, 2015 7:41 PM Unanswerable drive-by question
    Wednesday, December 17, 2014 10:44 AM

All replies

  • Use the proxy settings.  That is what they are for?


    ¯\_(ツ)_/¯

    Wednesday, December 17, 2014 1:56 PM
  • Of course, this works if I add the -Proxy and -ProxyUseDefaultCredentials options.

    but: If I want to code something that's context-independent, I need to retrieve (e.g. from the registry (?)) what values I have to specify to those arguments, and whether I need them (if the system doesn't use any proxy, I must not specify them).

    And: for some reason, I do not need to specify them when running under command-line powershell.exe.

    Also worth mentioning: the "Script Browser" ISE add-on doesn't work (anymore?), it displays "Network error." This means that something is wrong in how ISE determines the network/proxy settings.

    IOW: this is not a normal situation, and I need a fix.

    Wednesday, December 17, 2014 3:13 PM
  • Sorry but that is how the CmdLet is designed. We cannot fix that.

    You can get current proxy settings from "netsh winhttp show proxy"


    ¯\_(ツ)_/¯

    Wednesday, December 17, 2014 3:21 PM
  • I hate to say, but I don't understand how what I see is compatible with your statement.

    Let me show what I'm experiencing with more details.

    Here's what I get without any proxy options from powershell.exe:

    PS 4.0 ~> $r = iwr http://www.adobe.com
    PS 4.0 ~> $r -eq $null
    False
    PS 4.0 ~> $r.GetType()

    IsPublic IsSerial Name                                     BaseType
    -------- -------- ----                                     --------
    True     False    HtmlWebResponseObject                    Microsoft.PowerSh...

    and here's what I get from the ISE:

    PS ~> $r = iwr http://www.adobe.com


    iwr : The remote name could not be resolved: 'www.adobe.com'

    At line:1 char:6

    + $r = iwr http://www.adobe.com

    +      ~~~~~~~~~~~~~~~~~~~~~~~~

        + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-W

       ebRequest], WebException

        + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebR

       equestCommand


    PS ~> $r -eq $null

    True

    If the CmdLet requires the -proxy option, how do you explain the results I get without the option from powershell.exe?

    Next to that, here's what netsh reports:

    PS 4.0 ~> netsh winhttp show proxy

    Current WinHTTP proxy settings:

        Direct access (no proxy server).

    This is not what I have under "Internet Options", where "Automatically detect settings" and "Use automatic configuration script" are both checked. But IIRC from the proxycfg.exe days this reports the "system-wide" proxy settings, not the per-user proxy settings.

    Thursday, December 18, 2014 11:09 AM
  • What makes you think that has something to do with the proxy? I suspect an issue with the setup.

    Try logging into a different account and try the same thing.  Don't run ISE as Admin (elevated) to avoid some known issues.

    I can run that in ISE with no issues even on a system with a proxy configured in IE. 

    Do not check 'Use automatic configuration script' as this is known to cause some issues.  That is only useful if you are using third party proxy servers and it requires other things to be set up.  It can cause issues if not configured correctly.


    ¯\_(ツ)_/¯

    Thursday, December 18, 2014 11:34 AM
  • It's proxy-related since the error in ISE disappears if I add the -proxy and -proxyusedefaultcredentials options

    Behavior is exactly the same with another account.

    Using the proxy configuration script is required by our IT due to our infrastructure (esp. to make sure the right intranet domains are excluded).

    Thursday, December 18, 2014 12:15 PM
  • Well you may have an issue but it is not script related.  You will need to either call support or post a bug in Connect.  Can't help you much here.

    The proxy isset up by the Net Framework and not by PowerShell.  The only known difference between ISE and CLI is the threading model.


    ¯\_(ツ)_/¯


    • Edited by jrv Thursday, December 18, 2014 12:35 PM
    Thursday, December 18, 2014 12:33 PM
  • I agree that's not script-related.

    I have already filed a bug on Connect, but (as has been the case for many months now) I get no reaction there.

    I'll revert to PS3 and see what I get there; if it works I'll reinstall PS4 and test again.

    What is the proper forum for non-scripting-related issues with PowerShell?

    Thursday, December 18, 2014 12:41 PM
  • What is the proper forum for non-scripting-related issues with PowerShell?

    There really isn't as far as I can tell.


    ¯\_(ツ)_/¯

    Thursday, December 18, 2014 1:03 PM
  • Same problem with PS3!!!
    Thursday, December 18, 2014 1:04 PM
  • Same problem with PS5 Production Preview (5.0.10514.6) running on Windows 7 SP1, but it seems to work on Windows 10 Insider Preview build 10576 (PS 5.0.10576.0).

    Thursday, November 5, 2015 3:41 PM
  • I solved this the "Network Error: Please check your Internet connection..." issue by deleting the "user.config" files found under the
      %UserProfile%\AppData\Local\Microsoft_Corporation\ScriptBrowserDesktop.exe_...
    and
      %UserProfile%\AppData\Local\Microsoft_Corporation\powershell_ise.exe_...
    folders. I had to reconfigure both the Script Browser application and the Script Browser add-on in PowerShell ISE separately. But they both started working.

    Make sure that both the "Sample Download Location" and Proxy settings are correct.

    Thursday, December 6, 2018 7:43 PM