简体   繁体   中英

Powershell Install-Package from Nuget

I'm trying to follow Docker installation guide for Windows server 2016 ( https://blog.docker.com/2016/09/build-your-first-docker-windows-server-container/ ). When I execute

Install-Package -Name docker -ProviderName DockerMsftProvider

there is an error

Install-Package : A parameter cannot be found that matches parameter name 'DestinationPath'. At line:1 char:1 + Install-Package -Name docker -ProviderName DockerMsftProvider -Verbos ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception + FullyQualifiedErrorId : FailedToDownload,Install-Package,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

Seems like the package is found and downloaded but wrong install command is called for some reason. Any way to fix it? Here is the full verbose output for Install-Package command:

VERBOSE: Using the provider 'DockerMsftProvider' for searching packages. VERBOSE: Download size: 0MB VERBOSE: Free space on the drive: 166058.04MB VERBOSE: Downloading https://dockermsft.blob.core.windows.net/dockercontainer/DockerMsftIndex.json to C:\\Users\\me\\AppData\\Local\\Temp\\Do ckerMsftProvider\\DockerDefault_DockerSearchIndex.json VERBOSE: About to download VERBOSE: Finished downloading VERBOSE: Downloaded in 0 hours, 0 minutes, 1 seconds. VERBOSE: Performing the operation "Install Package" on target "Package 'Docker' version '1.12.2-cs2-ws-beta' from 'DockerDefault'.". VERBOSE: Containers feature is already installed. Skipping the install. VERBOSE: Download size: 13.53MB VERBOSE: Free space on the drive: 166058.04MB VERBOSE: Downloading https://dockermsft.blob.core.windows.net/dockercontainer/docker-1-12-2-cs2-ws-beta.zip to C:\\Users\\me\\AppData\\Loca l\\Temp\\DockerMsftProvider\\Docker-1-12-2-cs2-ws-beta.zip VERBOSE: About to download VERBOSE: Finished downloading VERBOSE: Downloaded in 0 hours, 0 minutes, 9 seconds. VERBOSE: Verifying Hash of the downloaded file. VERBOSE: Hash verified! VERBOSE: Found C:\\Users\\me\\AppData\\Local\\Temp\\DockerMsftProvider\\Docker-1-12-2-cs2-ws-beta.zip to install. VERBOSE: Trying to unzip : C:\\Users\\me\\AppData\\Local\\Temp\\DockerMsftProvider\\Docker-1-12-2-cs2-ws-beta.zip VERBOSE: Removing the archive: C:\\Users\\me\\AppData\\Local\\Temp\\DockerMsftProvider\\Docker-1-12-2-cs2-ws-beta.zip Install-Package : A parameter cannot be found that matches parameter name 'DestinationPath'. At line:1 char:1 + Install-Package -Name docker -ProviderName DockerMsftProvider -Verbos ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception + FullyQualifiedErrorId : FailedToDownload,Install-Package,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

UPD: Seems like the problem is with this line:

$null = Expand-Archive -Path $destination -DestinationPath $env:ProgramFiles -Force

But when called directly the Expand-Archive command is executed fine

I had the same problem.

I was due to the Powershell Community Extensions that I installed... There is a conflict on the command Expand-Archive with recent Powershell version.

You may not have to totally uninstall. If you have a PowerShell profile you can forcibly load the "standard" Expand-Archive command first, then tell PowerShell Community Extensions to not replace it:

Import-Module Microsoft.PowerShell.Archive
Import-Module Pscx -NoClobber

After that, you should be able to Get-Command Expand-Archive and you'll see the source is Microsoft.PowerShell.Archive rather than Pscx .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM