Uninstall-Package

Uninstalls one or more software packages.

Syntax

Uninstall-Package
         [-InputObject] <SoftwareIdentity[]>
         [-AllVersions]
         [-Force]
         [-ForceBootstrap]
         [-WhatIf]
         [-Confirm]
         [<CommonParameters>]
Uninstall-Package
         [-Name] <String[]>
         [-RequiredVersion <String>]
         [-MinimumVersion <String>]
         [-MaximumVersion <String>]
         [-AllVersions]
         [-Force]
         [-ForceBootstrap]
         [-WhatIf]
         [-Confirm]
         [-ProviderName <String[]>]
         [<CommonParameters>]
Uninstall-Package
         [-AllVersions]
         [-Force]
         [-ForceBootstrap]
         [-WhatIf]
         [-Confirm]
         [-Destination <String>]
         [-ExcludeVersion]
         [-Scope <String>]
         [-SkipDependencies]
         [<CommonParameters>]
Uninstall-Package
         [-AllVersions]
         [-Force]
         [-ForceBootstrap]
         [-WhatIf]
         [-Confirm]
         [-Destination <String>]
         [-ExcludeVersion]
         [-Scope <String>]
         [-SkipDependencies]
         [<CommonParameters>]
Uninstall-Package
         [-AllVersions]
         [-Force]
         [-ForceBootstrap]
         [-WhatIf]
         [-Confirm]
         [-Scope <String>]
         [-PackageManagementProvider <String>]
         [-Type <String>]
         [-AllowClobber]
         [-SkipPublisherCheck]
         [-InstallUpdate]
         [-NoPathUpdate]
         [-AllowPrereleaseVersions]
         [<CommonParameters>]
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.

Examples

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 )

Parameters

-AllowClobber

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

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AllowPrereleaseVersions

Allows packages marked as prerelease to be uninstalled.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AllVersions

Indicates that this cmdlet uninstalls all versions of the package.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Destination

Specifies a string of the path to the input object.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ExcludeVersion

Switch to exclude the version number in the folder path.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Force

Forces the command to run without asking for user confirmation.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ForceBootstrap

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

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters: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.

Type:Microsoft.PackageManagement.Packaging.SoftwareIdentity[]
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-InstallUpdate

Indicates that Uninstall-Package uninstalls updates.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters: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.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters: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.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Name

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

Type:String[]
Position:0
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters: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.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-PackageManagementProvider

Specifies the PackageManagement provider.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters: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.

Type:String[]
Aliases:Provider
Accepted values:Bootstrap, NuGet, PowerShellGet
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters: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.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Scope

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

  • CurrentUser
  • AllUsers
Type:String
Accepted values:CurrentUser, AllUsers
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-SkipDependencies

Skips the uninstallation of software dependencies.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters: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.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters: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
Type:String
Accepted values:Module, Script, All
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-WhatIf

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

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

Microsoft.PackageManagement.Packaging.SoftwareIdentity

You can pipe SoftwareIdentity objects to this cmdlet.

Outputs

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.