Invoke-WebRequest GetSystemWebProxy()

后端 未结 3 1442
深忆病人
深忆病人 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条回答
  •  旧时难觅i
    2021-02-09 04:02

    The actual problem with your code above (even though Shay's is more elegant) is that you're trying to set a property on a variable before it exists. The SessionVariable "$WS" doesn't exist before you call Invoke-WebRequest but you're trying to set the .Proxy property above it.

    If it worked at one point, you had probably created an instance of $WS previously and therefore were able to work with the object during testing but on a fresh/dry run when the script was processing top-down, it didn't yet exist.

提交回复
热议问题