-
-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Proxy parameters for commands that use Invoke-WebRequest or Invoke-RestMethod #396
Comments
Hi again, @FISHMANPET. Please forgive my ignorance here as I have very little experience dealing with environments that require using a proxy server. I was under the impression that the web cmdlets would already use the system-defined proxy settings if they exist. Though I seem to recall different versions of PowerShell or maybe just different versions of .NET having differing levels of support for that. I found an MS Docs article relating to using the Azure PowerShell module behind a proxy that suggests using the standard https://docs.microsoft.com/en-us/powershell/azure/az-powershell-proxy Would this potentially work for you? If for whatever reason we need to explicitly provide the Proxy parameters to the internal web calls, we can probably make it work via environment variables for base module functions. But every single plugin that makes web calls will need to be modified to support them as well. But at that point, it probably makes sense to create a wrapper functions the plugins can call instead. But that has cascading effects for some folks who are using the plugins as standalone scripts outside the module. So I'm really hoping we can figure something out that doesn't involve explicitly using the Proxy* parameters on Invoke-WebRequest and Invoke-RestMethod. |
Right now I'm using PS 5.1 on Windows, so the advice there is to "use the system proxy". Also, I believe the AZ Powershell module is actually using .Net calls directly under the hood rather than the Invoke- commands, so the behavior may be different. What I've been able to determine by experimenting is that if you set the "system" proxy ( I also agree that it would be a huge amount of work for what is probably a very small use case (seeing as how it's never come up until now). Maybe it's best for now to just put this on the "backlog" until other people ask for it. I think now that I've found that StackOverflow post on setting the registry values, even though it's complex it appears to be well defined and ultimately doable, I can go down that path myself without needing to make changes to the module. |
|
I'm in a situation where I'd like to be able to request a certificate for a system that requires a proxy to communicate with the outside world (including our certificate vendor). If I logon to a system and set the "Internet Options" to use our proxy server (which I believe Invoke-WebRequest and Invoke-RestMethod use) then I'm able to successfully install a certificate. While those Invoke commands will accept Proxy parameters, there's no way (that I can see) to pass those to the commands when they're used inside the module.
I can see a couple of ways to accomplish this (and I'd be more than happy to work on implementing them or any other suggestions, since I'm asking for it after all 😁)
First option, add a -Proxy, -ProxyCredential, and -ProxyUseDefaultCredentials to every command that will eventually result in an Invoke-Rest/Web call, to be used to pass to those commands when needed.
Second Option, use something similar to
$env:POSHACME_HOME
and set a script variable in Import-PAConfig that will be added to every Invoke command, the same way$script:UseBasic
is added to every command currently.I'm also open to working on a different implementation suggestion if you have any, or some way to accomplish this without having to modify the module itself.
The text was updated successfully, but these errors were encountered: