Invoke-WebRequest GetSystemWebProxy()

后端 未结 3 1397
深忆病人
深忆病人 2021-02-09 03:09

Under PowerShell 2.0 I know that you can set the proxy you would like to use without knowing the exact proxy settings by doing something like the following:

$pro         


        
3条回答
  •  [愿得一人]
    2021-02-09 03:57

    Maybe this can help, I keep it in my profile. It is using the new the $PSDefaultParameterValues preference variable to set the default proxy values for the new web cmdlets. The code detects if I'm in my office environment and set the settings accordingly. This saves me specifying the settings each time I use those commands.

    if(Test-Connection myCorpProxy -Count 1 -Quiet)
    {
        $global:PSDefaultParameterValues = @{
            'Invoke-RestMethod:Proxy'='http://myCorpProxy:8080'
            'Invoke-WebRequest:Proxy'='http://myCorpProxy:8080'
            '*:ProxyUseDefaultCredentials'=$true
        }
    }
    

提交回复
热议问题