Install-Package
Installs one or more software packages.
语法
PackageBySearch (默认值)
Install-Package
[-Name] <String[]>
[-RequiredVersion <String>]
[-MinimumVersion <String>]
[-MaximumVersion <String>]
[-Source <String[]>]
[-Credential <PSCredential>]
[-Proxy <Uri>]
[-ProxyCredential <PSCredential>]
[-AllVersions]
[-Force]
[-ForceBootstrap]
[-WhatIf]
[-Confirm]
[-ProviderName <String[]>]
[<CommonParameters>]
Install-Package
[-InputObject] <SoftwareIdentity[]>
[-Credential <PSCredential>]
[-Proxy <Uri>]
[-ProxyCredential <PSCredential>]
[-AllVersions]
[-Force]
[-ForceBootstrap]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
NuGet:PackageBySearch
Install-Package
[-Credential <PSCredential>]
[-Proxy <Uri>]
[-ProxyCredential <PSCredential>]
[-AllVersions]
[-Force]
[-ForceBootstrap]
[-WhatIf]
[-Confirm]
[-ConfigFile <String>]
[-SkipValidate]
[-Headers <String[]>]
[-FilterOnTag <String[]>]
[-Contains <String>]
[-AllowPrereleaseVersions]
[-Destination <String>]
[-ExcludeVersion]
[-Scope <String>]
[-SkipDependencies]
[<CommonParameters>]
Install-Package
[-Credential <PSCredential>]
[-Proxy <Uri>]
[-ProxyCredential <PSCredential>]
[-AllVersions]
[-Force]
[-ForceBootstrap]
[-WhatIf]
[-Confirm]
[-ConfigFile <String>]
[-SkipValidate]
[-Headers <String[]>]
[-FilterOnTag <String[]>]
[-Contains <String>]
[-AllowPrereleaseVersions]
[-Destination <String>]
[-ExcludeVersion]
[-Scope <String>]
[-SkipDependencies]
[<CommonParameters>]
PowerShellGet:PackageBySearch
Install-Package
[-Credential <PSCredential>]
[-Proxy <Uri>]
[-ProxyCredential <PSCredential>]
[-AllVersions]
[-Force]
[-ForceBootstrap]
[-WhatIf]
[-Confirm]
[-AllowPrereleaseVersions]
[-Scope <String>]
[-PackageManagementProvider <String>]
[-PublishLocation <String>]
[-ScriptSourceLocation <String>]
[-ScriptPublishLocation <String>]
[-Type <String>]
[-Filter <String>]
[-Tag <String[]>]
[-Includes <String[]>]
[-DscResource <String[]>]
[-RoleCapability <String[]>]
[-Command <String[]>]
[-AcceptLicense]
[-AllowClobber]
[-SkipPublisherCheck]
[-InstallUpdate]
[-NoPathUpdate]
[<CommonParameters>]
Install-Package
[-Credential <PSCredential>]
[-Proxy <Uri>]
[-ProxyCredential <PSCredential>]
[-AllVersions]
[-Force]
[-ForceBootstrap]
[-WhatIf]
[-Confirm]
[-AllowPrereleaseVersions]
[-Scope <String>]
[-PackageManagementProvider <String>]
[-PublishLocation <String>]
[-ScriptSourceLocation <String>]
[-ScriptPublishLocation <String>]
[-Type <String>]
[-Filter <String>]
[-Tag <String[]>]
[-Includes <String[]>]
[-DscResource <String[]>]
[-RoleCapability <String[]>]
[-Command <String[]>]
[-AcceptLicense]
[-AllowClobber]
[-SkipPublisherCheck]
[-InstallUpdate]
[-NoPathUpdate]
[<CommonParameters>]
说明
The Install-Package
cmdlet installs one or more software packages on the local computer. If you
have multiple software sources, use Get-PackageProvider
and Get-PackageSource
to display details
about your providers.
Important
The commands contained in the PackageManagement module are different than the commands
provided by the NuGet module in the Package Manager Console of Visual Studio. Each module has
commands that are not available in the other. Commands with the same name differ in their specific
arguments. For more information, see the PowerShell reference documentation for the
Package Manager Console of Visual Studio.
示例
Example 1: Install a package by package name
The Install-Package
cmdlet installs a software package and its dependencies.
PS> Install-Package -Name NuGet.Core -Source MyNuGet -Credential Contoso\TestUser
Install-Package
uses parameters to specify the packages Name and Source . The
Credential parameter uses a domain user account with permissions to install packages. The
command prompts you for the user account password.
Example 2: Use Find-Package to install a package
In this example, the object returned by Find-Package
is sent down the pipeline and installed by
Install-Package
.
PS> Find-Package -Name NuGet.Core -Source MyNuGet | Install-Package
Find-Package
uses the Name and Source parameters to locate a package. The object is sent
down the pipeline and Install-Package
installs the package on the local computer.
Example 3: Install packages by specifying a range of versions
Install-Package
uses the MinimumVersion and MaximumVersion parameters to specify a range
of software versions.
PS> Install-Package -Name NuGet.Core -Source MyNuGet -MinimumVersion 2.8.0 -MaximumVersion 2.9.0
Install-Package
uses the Name and Source parameters to find a package. The
MinimumVersion and MaximumVersion parameters specify a range of software versions. The
highest version in the range is installed.
参数
-AcceptLicense
AcceptLicense automatically accepts the license agreement during installation.
参数属性
参数集
PowerShellGet:PackageBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
PowerShellGet:PackageByInputObject
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-AllowClobber
Overrides warning messages about conflicts with existing commands. Overwrites existing commands that
have the same name as commands being installed.
参数属性
参数集
PowerShellGet:PackageBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
PowerShellGet:PackageByInputObject
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-AllowPrereleaseVersions
Allows the installation of packages marked as prerelease.
参数属性
参数集
NuGet:PackageBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
NuGet:PackageByInputObject
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
PowerShellGet:PackageBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
PowerShellGet:PackageByInputObject
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-AllVersions
Install-Package
installs all available versions of the package. By default, only the newest
version is installed.
参数属性
参数集
(All)
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-Command
Specifies one or more commands that Install-Package
searches.
参数属性
类型: String [ ]
默认值: None
支持通配符: False
不显示: False
参数集
PowerShellGet:PackageBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
PowerShellGet:PackageByInputObject
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-ConfigFile
Specifies a path that contains a configuration file.
参数属性
类型: String
默认值: None
支持通配符: False
不显示: False
参数集
NuGet:PackageBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
NuGet:PackageByInputObject
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-Confirm
Prompts you for confirmation before running the cmdlet.
参数属性
参数集
(All)
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-Contains
Install-Package
gets objects if the Contains parameter specifies a value that matches any of
the object's property values.
参数属性
类型: String
默认值: None
支持通配符: False
不显示: False
参数集
NuGet:PackageBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
NuGet:PackageByInputObject
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-Credential
Specifies a user account that has permission to access the computer and run commands. Type a user
name, such as User01 , Domain01\User01 , or enter a PSCredential object, generated by the
Get-Credential
cmdlet. If you type a user name, you're prompted for a password.
When the Credential parameter isn't specified, Install-Package
uses the current user.
参数属性
参数集
(All)
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-Destination
Specifies a path to an input object.
参数属性
类型: String
默认值: None
支持通配符: False
不显示: False
参数集
NuGet:PackageBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
NuGet:PackageByInputObject
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-DscResource
Specifies one or more Desired State Configuration (DSC) resources that are searched by
Install-Package
. Use the Find-DscResource
cmdlet to find DSC resources.
参数属性
类型: String [ ]
默认值: None
支持通配符: False
不显示: False
参数集
PowerShellGet:PackageBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
PowerShellGet:PackageByInputObject
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-ExcludeVersion
Switch to exclude the version number in the folder path.
参数属性
参数集
NuGet:PackageBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
NuGet:PackageByInputObject
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-Filter
Specifies terms to search for within the Name and Description properties.
参数属性
类型: String
默认值: None
支持通配符: False
不显示: False
参数集
PowerShellGet:PackageBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
PowerShellGet:PackageByInputObject
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-FilterOnTag
Specifies a tag that filters results and excludes results that don't contain the specified tag.
参数属性
类型: String [ ]
默认值: None
支持通配符: False
不显示: False
参数集
NuGet:PackageBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
NuGet:PackageByInputObject
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-Force
Forces the command to run without asking for user confirmation. Overrides restrictions that prevent
Install-Package
from succeeding, with the exception of security.
参数属性
参数集
(All)
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-ForceBootstrap
Forces PackageManagement to automatically install the package provider for the specified
package.
参数属性
参数集
(All)
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
Specifies the package headers.
类型: String [ ]
默认值: None
支持通配符: False
不显示: False
NuGet:PackageBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
NuGet:PackageByInputObject
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-Includes
Specifies whether Install-Package
should find all package types. The acceptable values for this
parameter are as follows:
Cmdlet
DscResource
Function
RoleCapability
Workflow
参数属性
类型: String [ ]
默认值: None
接受的值: Cmdlet, DscResource, Function, RoleCapability, Workflow
支持通配符: False
不显示: False
参数集
PowerShellGet:PackageBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
PowerShellGet:PackageByInputObject
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
Accepts pipeline input. Specifies a package by using the package's SoftwareIdentity type.
Find-Package
outputs a SoftwareIdentity object.
类型: Microsoft.PackageManagement.Packaging.SoftwareIdentity [ ]
默认值: None
支持通配符: False
不显示: False
PackageByInputObject
Position: 0
必需: True
来自管道的值: True
来自管道的值(按属性名称): False
来自剩余参数的值: False
-InstallUpdate
Indicates that Install-Package
installs updates.
参数属性
参数集
PowerShellGet:PackageBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
PowerShellGet:PackageByInputObject
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-MaximumVersion
Specifies the maximum allowed package version that you want to install. If you don't specify this
parameter, Install-Package
installs the package's newest version.
参数属性
类型: String
默认值: None
支持通配符: False
不显示: False
参数集
PackageBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-MinimumVersion
Specifies the minimum allowed package version that you want to install. If you don't add this
parameter, Install-Package
installs the package's newest version that satisfies any version
specified by the MaximumVersion parameter.
参数属性
类型: String
默认值: None
支持通配符: False
不显示: False
参数集
PackageBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-Name
Specifies one or more package names. Multiple package names must be separated by commas.
参数属性
类型: String [ ]
默认值: None
支持通配符: False
不显示: False
参数集
PackageBySearch
Position: 0
必需: True
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-NoPathUpdate
NoPathUpdate only applies to the Install-Script
cmdlet. NoPathUpdate is a dynamic
parameter added by the provider and isn't supported by Install-Package
.
参数属性
参数集
PowerShellGet:PackageBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
PowerShellGet:PackageByInputObject
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-PackageManagementProvider
Specifies the name of the PackageManagement provider.
参数属性
类型: String
默认值: None
支持通配符: False
不显示: False
参数集
PowerShellGet:PackageBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
PowerShellGet:PackageByInputObject
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-ProviderName
Specifies one or more package provider names to which to scope your package search. You can get
package provider names by running the Get-PackageProvider
cmdlet.
参数属性
类型: String [ ]
默认值: None
接受的值: Bootstrap, NuGet, PowerShellGet
支持通配符: False
不显示: False
别名: Provider
参数集
PackageBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): True
来自剩余参数的值: False
-Proxy
Specifies a proxy server for the request, rather than connecting directly to an internet resource.
参数属性
类型: Uri
默认值: None
支持通配符: False
不显示: False
参数集
(All)
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-ProxyCredential
Specifies a user account that has permission to use the proxy server specified by the Proxy
parameter.
参数属性
参数集
(All)
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-PublishLocation
Specifies the path to a package's published location.
参数属性
类型: String
默认值: None
支持通配符: False
不显示: False
参数集
PowerShellGet:PackageBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
PowerShellGet:PackageByInputObject
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-RequiredVersion
Specifies the exact allowed version of the package that you want to install. If you don't add this
parameter, Install-Package
installs the package's newest version that satisfies any version
specified by the MaximumVersion parameter.
参数属性
类型: String
默认值: None
支持通配符: False
不显示: False
参数集
PackageBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-RoleCapability
Specifies an array of role capabilities.
参数属性
类型: String [ ]
默认值: None
支持通配符: False
不显示: False
参数集
PowerShellGet:PackageBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
PowerShellGet:PackageByInputObject
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-Scope
Specifies the scope for which to install the package. The acceptable values for this parameter are
as follows:
参数属性
类型: String
默认值: None
接受的值: CurrentUser, AllUsers
支持通配符: False
不显示: False
参数集
NuGet:PackageBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
NuGet:PackageByInputObject
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
PowerShellGet:PackageBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
PowerShellGet:PackageByInputObject
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-ScriptPublishLocation
Specifies the path to a script's published location.
参数属性
类型: String
默认值: None
支持通配符: False
不显示: False
参数集
PowerShellGet:PackageBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
PowerShellGet:PackageByInputObject
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-ScriptSourceLocation
Specifies the script source location.
参数属性
类型: String
默认值: None
支持通配符: False
不显示: False
参数集
PowerShellGet:PackageBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
PowerShellGet:PackageByInputObject
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-SkipDependencies
Skips the installation of software dependencies.
参数属性
参数集
NuGet:PackageBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
NuGet:PackageByInputObject
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-SkipPublisherCheck
Allows you to get a package version that is newer than your installed version. For example, an
installed package that is digitally signed by a trusted publisher but a new version isn't digitally
signed.
参数属性
参数集
PowerShellGet:PackageBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
PowerShellGet:PackageByInputObject
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-SkipValidate
Switch that skips validating the credentials of a package.
参数属性
参数集
NuGet:PackageBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
NuGet:PackageByInputObject
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-Source
Specifies one or more package sources. Multiple package source names must be separated by commas.
You can get package source names by running the Get-PackageSource
cmdlet.
参数属性
类型: String [ ]
默认值: None
支持通配符: False
不显示: False
参数集
PackageBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): True
来自剩余参数的值: False
-Tag
Specifies one or more strings to search for in the package metadata.
参数属性
类型: String [ ]
默认值: None
支持通配符: False
不显示: False
参数集
PowerShellGet:PackageBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
PowerShellGet:PackageByInputObject
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-Type
Specifies whether to search for packages with a module, a script, or both. The acceptable values for
this parameter are as follows:
参数属性
类型: String
默认值: None
接受的值: Module, Script, All
支持通配符: False
不显示: False
参数集
PowerShellGet:PackageBySearch
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
PowerShellGet:PackageByInputObject
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-WhatIf
Shows what would happen if Install-Package
cmdlet is run. The cmdlet is not run.
参数属性
参数集
(All)
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable,
-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see
about_CommonParameters .
You can pipe a SoftwareIdentity object to this cmdlet.
输出
Microsoft.PackageManagement.Packaging.SoftwareIdentity
This cmdlet returns a SoftwareIdentity object for each package it installs.
备注
Including a package provider in a command can make dynamic parameters available to a cmdlet. Dynamic
parameters are specific to a package provider. The Get-Help
cmdlet lists a cmdlet's parameter sets
and includes the provider's parameter set. For example, Install-Package
has the PowerShellGet
parameter set that includes -NoPathUpdate
, AllowClobber
, and SkipPublisherCheck
.
Important
As of April 2020, the PowerShell Gallery no longer supports Transport Layer Security (TLS)
versions 1.0 and 1.1. If you are not using TLS 1.2 or higher, you will receive an error when
trying to access the PowerShell Gallery. Use the following command to ensure you are using TLS
1.2:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
For more information, see the
announcement in the
PowerShell blog.