How to run powershell Azure cmdlet through a proxy with credentials?

When I run the following Powershell cmdlet (from Snapin Azure Management Tools):

get-osversions -subscriptionId **** -certificate (get-item cert:\CurrentUser\MY\******) 

The following error message appears:

Get-OSVersions: The remote server returned an unexpected response: (407) Proxy Authenti Cation required. On the line: 1 char: 15 + get-osversions <<<< - subscriptionId * -certificate (get-item cert: \ CurrentUser \ MY *****) + CategoryInfo: CloseError: (:) [Get-OSVersions], ProtocolException + FullyQualifiedErrorId: Microsoft.Samples.AzureManagementTools.PowerShell.HostedS ervices.GetOSVersionsCommand

Get-OSVersions: the reference to the object is not installed in the instance of the object. On line: 1 char: 15 + get-osversions <<<< - subscriptionId * -certificate (get-item cert: \ CurrentUser \ MY ** * ) + CategoryInfo: CloseError: (:) [Get-OSVersions], exception NullReferenceException + FullyQualifiedErrorId: Microsoft.Samples.AzureManagementTools.PowerShell.HostedS ervices.GetOSVersionsCommand

It seems that the internet proxy here denies the script access that it requires.

I had a good look on the Internet, and it seems that this is not a problem, since this cmdlet does not have a valid "-credentials" parameter or proxy server.

I know there is a Get-Credential cmdlet, but I don't think this helps. How do you pass credentials to the Azure cmdlet?

Can anyone think of any way around this problem? ..

... other than using another non-proxied internet connection?

I'm at a dead end.

Thanks so much for your time.

+6
source share
2 answers

Several clients that I know have been successful using the method described here ( Basic Auth proxy support ). If you need other types of proxies, it follows the same pattern. The best part about this is that it does not require changing cmdlets.

+1
source

easier:

 [System.Net.WebRequest]::DefaultWebProxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials 
+15
source

Source: https://habr.com/ru/post/893508/


All Articles