Partager via


Uninstall-Package

Uninstalls one or more software packages.

Syntaxe

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>]

Description

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.

Exemples

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 )

Paramètres

-AllowClobber

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

Parameter properties

Type:SwitchParameter
Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

PowerShellGet:PackageByInputObject
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
PowerShellGet:PackageBySearch
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-AllowPrereleaseVersions

Allows packages marked as prerelease to be uninstalled.

Parameter properties

Type:SwitchParameter
Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

PowerShellGet:PackageByInputObject
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
PowerShellGet:PackageBySearch
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-AllVersions

Indicates that this cmdlet uninstalls all versions of the package.

Parameter properties

Type:SwitchParameter
Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Parameter properties

Type:SwitchParameter
Valeur par défaut:False
Supports wildcards:False
DontShow:False
Alias:cf

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Destination

Specifies a string of the path to the input object.

Parameter properties

Type:String
Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

NuGet:PackageByInputObject
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
NuGet:PackageBySearch
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ExcludeVersion

Switch to exclude the version number in the folder path.

Parameter properties

Type:SwitchParameter
Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

NuGet:PackageByInputObject
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
NuGet:PackageBySearch
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Force

Forces the command to run without asking for user confirmation.

Parameter properties

Type:SwitchParameter
Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ForceBootstrap

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

Parameter properties

Type:SwitchParameter
Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments: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.

Parameter properties

Type:

Microsoft.PackageManagement.Packaging.SoftwareIdentity[]

Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

PackageByInputObject
Position:0
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-InstallUpdate

Indicates that Uninstall-Package uninstalls updates.

Parameter properties

Type:SwitchParameter
Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

PowerShellGet:PackageByInputObject
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
PowerShellGet:PackageBySearch
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments: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.

Parameter properties

Type:String
Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

PackageBySearch
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments: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.

Parameter properties

Type:String
Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

PackageBySearch
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Name

Specifies one or more package names. Multiple package names must be separated by commas.

Parameter properties

Type:

String[]

Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

PackageBySearch
Position:0
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments: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.

Parameter properties

Type:SwitchParameter
Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

PowerShellGet:PackageByInputObject
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
PowerShellGet:PackageBySearch
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-PackageManagementProvider

Specifies the PackageManagement provider.

Parameter properties

Type:String
Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

PowerShellGet:PackageByInputObject
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
PowerShellGet:PackageBySearch
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments: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.

Parameter properties

Type:

String[]

Valeur par défaut:None
Valeurs acceptées:Bootstrap, NuGet, PowerShellGet
Supports wildcards:False
DontShow:False
Alias:Provider

Parameter sets

PackageBySearch
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments: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.

Parameter properties

Type:String
Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

PackageBySearch
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Scope

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

  • CurrentUser
  • AllUsers

Parameter properties

Type:String
Valeur par défaut:None
Valeurs acceptées:CurrentUser, AllUsers
Supports wildcards:False
DontShow:False

Parameter sets

NuGet:PackageByInputObject
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
NuGet:PackageBySearch
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
PowerShellGet:PackageByInputObject
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
PowerShellGet:PackageBySearch
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-SkipDependencies

Skips the uninstallation of software dependencies.

Parameter properties

Type:SwitchParameter
Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

NuGet:PackageByInputObject
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
NuGet:PackageBySearch
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments: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.

Parameter properties

Type:SwitchParameter
Valeur par défaut:None
Supports wildcards:False
DontShow:False

Parameter sets

PowerShellGet:PackageByInputObject
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
PowerShellGet:PackageBySearch
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments: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

Parameter properties

Type:String
Valeur par défaut:None
Valeurs acceptées:Module, Script, All
Supports wildcards:False
DontShow:False

Parameter sets

PowerShellGet:PackageByInputObject
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
PowerShellGet:PackageBySearch
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-WhatIf

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

Parameter properties

Type:SwitchParameter
Valeur par défaut:False
Supports wildcards:False
DontShow:False
Alias:wi

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments: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.

Entrées

Microsoft.PackageManagement.Packaging.SoftwareIdentity

You can pipe SoftwareIdentity objects to this cmdlet.

Sorties

Microsoft.PackageManagement.Packaging.SoftwareIdentity

This cmdlet returns a SoftwareIdentity object for each package uninstalled.

Notes

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.