Docker – Powershell behind a proxy

docker, docker-for-windows, nuget, powershell, proxy

I have installed Docker For Windows and when I want to install posh-docker with Install-Module posh-docker, I have this error message :

AVERTISSEMENT : Impossible de télécharger à partir de l'URI'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409' dans ''.AVERTISSEMENT : Impossible de télécharger la liste des fournisseurs disponibles.Vérifiez votre connexion Internet.PackageManagement\Install-PackageProvider : Aucune correspondance trouvée pour les critèresde recherche spécifiés pour le fournisseur 'NuGet'. Le fournisseur de package requiertles balises 'PackageManagement' et 'Provider'.Vérifiez si le package spécifié présente ces balises.Au caractère C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:7468 : 21+ ...     $null = PackageManagement\Install-PackageProvider -Name $script:N ...+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo          : InvalidArgument : (Microsoft.Power...PackageProvider:InstallPackageProvider)[Install-PackageProvider], Exception+ FullyQualifiedErrorId : NoMatchFoundForProvider,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProviderPackageManagement\Import-PackageProvider : Aucune correspondance trouvée pour le critère derecherche spécifié et le fournisseur de nom « NuGet ».Essayez « Get-PackageProvider -ListAvailable » si le fournisseur existe déjà sur le système.Au caractère C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:7474 : 21+ ...     $null = PackageManagement\Import-PackageProvider -Name $script:Nu ...+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo          : InvalidData : (NuGet:String) [Import-PackageProvider], Exception+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.ImportPackageProvider

In other words, Powershell doesn't access to Internet. In english :

WARNING: Unable to download the list of available providers. Check your internet connection.Install-PackageProvider : No match was found for the specified search criteria for theprovider 'NuGet'. The package provider requires 'PackageManagement' and 'Provider' tags.Please check if the specified package has the tags.

What I have tried

> netsh winhttp set proxy my_proxy:port> netsh winhttp show proxy

The netsh winhttp show proxy command displays my_proxy:port. After that, I set my credentials like that :

> $webclient=New-Object System.Net.WebClient> $creds=Get-Credential> $webclient.Proxy.Credentials=$creds

Don't work…

I tried this :

> $ProxyAddress = 'http://myproxy.contoso.com'> $ProxyCredentials = Get-Credential> $null = & netsh @('winhttp','set','proxy',$ProxyAddress)> $webclient=New-Object System.Net.WebClient> $webclient.Proxy.Credentials = $ProxyCredentials

Don't work…

Next :

> Install-Module posh-docker -Proxy http://my.proxy.int:9999 -ProxyCredential $ProxyCredentials

And… still.don't.work…

When I test with Update-Help command, I have this error message :

Update-Help : Échec lors de la mise à jour de l’aide du ou des modules «AppBackgroundTask,AppLocker, AppvClient, Appx, AssignedAccess, BitLocker, BitsTransfer, BranchCache,CimCmdlets, ConfigCI, Defender, DirectAccessClientComponents, Dism, DnsClient,EventTracingManagement, HgsClient, HgsDiagnostics, HostComputeService, Hyper-V,International, iSCSI, ISE, Kds, Microsoft.PowerShell.Archive, Microsoft.PowerShell.Core,Microsoft.PowerShell.Diagnostics, Microsoft.PowerShell.Host, Microsoft.PowerShell.LocalAccounts,Microsoft.PowerShell.Management, Microsoft.PowerShell.ODataUtils, Microsoft.PowerShell.Operation.Validation,Microsoft.PowerShell.Security, Microsoft.PowerShell.Utility, Microsoft.WSMan.Management,MMAgent, MsDtc, NetAdapter, NetConnection, NetEventPacketCapture, NetLbfo, NetNat, NetQos,NetSecurity, NetSwitchTeam, NetTCPIP, NetWNV, NetworkConnectivityStatus, NetworkSwitchManager,NetworkTransition, PackageManagement, PcsvDevice, PKI, PnpDevice, PowerShellGet,PrintManagement, Provisioning, PSDesiredStateConfiguration, PSReadline, PSScheduledJob,PSWorkflow, PSWorkflowUtility, ScheduledTasks, SecureBoot, SmbShare, SmbWitness, StartLayout,Storage, TLS, TroubleshootingPack, TrustedPlatformModule, UEV, VpnClient, Wdac, WindowsDeveloperLicense,WindowsErrorReporting, WindowsSearch, WindowsUpdate» avec la ou les cultures d’interfaceutilisateur {fr-FR} : Impossible de se connecter au contenu de l’aide. Le serveur sur lequelle contenu de l’aide est stocké est peut-être inaccessible. Vérifiez que le serveur est disponibleou attendez qu’il soit de nouveau en ligne, puis réessayez d’exécuter la commande.Au caractère Ligne:1 : 1+ Update-Help+ ~~~~~~~~~~~    + CategoryInfo          : InvalidOperation : (:) [Update-Help], Exception    + FullyQualifiedErrorId : UnableToConnect,Microsoft.PowerShell.Commands.UpdateHelpCommand

Any idea?

Thanks.

Best Solution

It's ok.The problem was that executing PowerShell as admin (with another admin user) was changing the user context and this admin user has no internet access...