Uninstall-Package

Uninstalls one or more software packages.

语法

PackageByInputObject

Uninstall-Package
    [-InputObject] <SoftwareIdentity[]>
    [-AllVersions]
    [-Force]
    [-ForceBootstrap]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

PackageBySearch

Uninstall-Package
    [-Name] <String[]>
    [-RequiredVersion <String>]
    [-MinimumVersion <String>]
    [-MaximumVersion <String>]
    [-AllVersions]
    [-Force]
    [-ForceBootstrap]
    [-WhatIf]
    [-Confirm]
    [-ProviderName <String[]>]
    [<CommonParameters>]

NuGet:PackageByInputObject

Uninstall-Package
    [-AllVersions]
    [-Force]
    [-ForceBootstrap]
    [-WhatIf]
    [-Confirm]
    [-Destination <String>]
    [-ExcludeVersion]
    [-Scope <String>]
    [-SkipDependencies]
    [<CommonParameters>]

NuGet:PackageBySearch

Uninstall-Package
    [-AllVersions]
    [-Force]
    [-ForceBootstrap]
    [-WhatIf]
    [-Confirm]
    [-Destination <String>]
    [-ExcludeVersion]
    [-Scope <String>]
    [-SkipDependencies]
    [<CommonParameters>]

PowerShellGet:PackageByInputObject

Uninstall-Package
    [-AllVersions]
    [-Force]
    [-ForceBootstrap]
    [-WhatIf]
    [-Confirm]
    [-Scope <String>]
    [-PackageManagementProvider <String>]
    [-Type <String>]
    [-AllowClobber]
    [-SkipPublisherCheck]
    [-InstallUpdate]
    [-NoPathUpdate]
    [-AllowPrereleaseVersions]
    [<CommonParameters>]

PowerShellGet:PackageBySearch

Uninstall-Package
    [-AllVersions]
    [-Force]
    [-ForceBootstrap]
    [-WhatIf]
    [-Confirm]
    [-Scope <String>]
    [-PackageManagementProvider <String>]
    [-Type <String>]
    [-AllowClobber]
    [-SkipPublisherCheck]
    [-InstallUpdate]
    [-NoPathUpdate]
    [-AllowPrereleaseVersions]
    [<CommonParameters>]

说明

The Uninstall-Package cmdlet uninstalls one or more software packages from the local computer. To find installed packages, use the Get-Package cmdlet.

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: Uninstall a package

The Uninstall-Package cmdlet uninstalls packages. The Name parameter specifies the package to uninstall. If multiple versions of a package are installed, the newest version is uninstalled.

PS> Uninstall-Package -Name NuGet.Core

Example 2: Use the pipeline to uninstall a package

Get-Package locates a specific package and sends the SoftwareIdentity object down the pipeline to the Uninstall-Package cmdlet.

PS> Get-Package -Name NuGet.Core -RequiredVersion 2.14.0 | Uninstall-Package

The Get-Package cmdlet uses the Name and RequiredVersion parameters to specify a package. A SoftwareIdentity object is sent down the pipeline. The Uninstall-Package cmdlet receives the object as an InputObject and removes the package.

As an alternative, the Uninstall-Package cmdlet can specify a value for the InputObject parameter:

Uninstall-Package -InputObject ( Get-Package -Name NuGet.Core -RequiredVersion 2.14.0 )

参数

-AllowClobber

Overrides warning messages about conflicts with existing commands. Overwrites existing commands that have the same name as commands being installed.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

PowerShellGet:PackageByInputObject
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
PowerShellGet:PackageBySearch
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-AllowPrereleaseVersions

Allows packages marked as prerelease to be uninstalled.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

PowerShellGet:PackageByInputObject
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
PowerShellGet:PackageBySearch
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-AllVersions

Indicates that this cmdlet uninstalls all versions of the package.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Confirm

Prompts you for confirmation before running the cmdlet.

参数属性

类型:SwitchParameter
默认值:False
支持通配符:False
不显示:False
别名:cf

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Destination

Specifies a string of the path to the input object.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

NuGet:PackageByInputObject
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
NuGet:PackageBySearch
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-ExcludeVersion

Switch to exclude the version number in the folder path.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

NuGet:PackageByInputObject
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
NuGet:PackageBySearch
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Force

Forces the command to run without asking for user confirmation.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-ForceBootstrap

Forces PackageManagement to automatically install the package provider for the specified package.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-InputObject

Accepts pipeline input that specifies the package's SoftwareIdentity object from the Get-Package cmdlet. InputObject accepts the SoftwareIdentity object as a Get-Package value or a variable that contains the object.

参数属性

类型:

Microsoft.PackageManagement.Packaging.SoftwareIdentity[]

默认值:None
支持通配符:False
不显示:False

参数集

PackageByInputObject
Position:0
必需:True
来自管道的值:True
来自管道的值(按属性名称):False
来自剩余参数的值:False

-InstallUpdate

Indicates that Uninstall-Package uninstalls updates.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

PowerShellGet:PackageByInputObject
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
PowerShellGet:PackageBySearch
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-MaximumVersion

Specifies the maximum allowed package version that you want to uninstall. If you don't specify this parameter, Uninstall-Package uninstalls 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 uninstall. If you don't add this parameter, Uninstall-Package uninstalls 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 Uninstall-Package.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

PowerShellGet:PackageByInputObject
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
PowerShellGet:PackageBySearch
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-PackageManagementProvider

Specifies the PackageManagement provider.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

PowerShellGet:PackageByInputObject
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
PowerShellGet:PackageBySearch
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-ProviderName

Specifies one or more package provider names to search for packages. 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

-RequiredVersion

Specifies the exact allowed version of the package that you want to uninstall. If you don't add this parameter, Uninstall-Package uninstalls 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

-Scope

Specifies the scope for which to uninstall the package. The acceptable values for this parameter are as follows:

  • CurrentUser
  • AllUsers

参数属性

类型:String
默认值:None
接受的值:CurrentUser, AllUsers
支持通配符:False
不显示:False

参数集

NuGet:PackageByInputObject
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
NuGet:PackageBySearch
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
PowerShellGet:PackageByInputObject
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
PowerShellGet:PackageBySearch
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-SkipDependencies

Skips the uninstallation of software dependencies.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

NuGet:PackageByInputObject
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
NuGet:PackageBySearch
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.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

PowerShellGet:PackageByInputObject
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
PowerShellGet:PackageBySearch
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:

  • Module
  • Script
  • All

参数属性

类型:String
默认值:None
接受的值:Module, Script, All
支持通配符:False
不显示:False

参数集

PowerShellGet:PackageByInputObject
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
PowerShellGet:PackageBySearch
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-WhatIf

Shows what would happen if Uninstall-Package cmdlet is run. The cmdlet isn't run.

参数属性

类型:SwitchParameter
默认值:False
支持通配符:False
不显示:False
别名:wi

参数集

(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.

输入

Microsoft.PackageManagement.Packaging.SoftwareIdentity

You can pipe SoftwareIdentity objects to this cmdlet.

输出

Microsoft.PackageManagement.Packaging.SoftwareIdentity

This cmdlet returns a SoftwareIdentity object for each package uninstalled.

备注

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, Uninstall-Package has the PowerShellGet parameter set that includes -NoPathUpdate, AllowClobber, and SkipPublisherCheck.