EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • Featured Skills
    • New & Trending
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Log in
  • Sign Up
Home Data Science Data Science Tutorials PowerShell Tutorial PowerShell uninstall module
 

PowerShell uninstall module

Updated March 4, 2023

PowerShell uninstall module

 

 

Introduction to PowerShell uninstall module

Uninstall-Module cmdlet in PowerShell which ships with PowerShellGet module,  uninstalls the specific module (multiple modules as well) and specific version that is installed on the local computer in the local user profile or the current user profile and it fails to uninstall when the module has the dependency on the other modules and with the PowerShell remoting methods, we can uninstall module on the remote computers as well.

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

Syntax

Uninstall-Module Syntax:

Uninstall-Module
[-Name] <String[]>
[-MinimumVersion <String>] [-RequiredVersion <String>] [-MaximumVersion <String>] [-AllVersions] [-Force] [-AllowPrerelease] [-WhatIf] [-Confirm] [<CommonParameters>] Uninstall-Module
[-InputObject] <PSObject[]>
[-Force] [-WhatIf] [-Confirm] [<CommonParameters>]

Syntax explanation:

-Name:  Modules to uninstall. You can provide multiple module names, separated by comma (,).

-MinimumVersion: When there are multiple versions of the module installed, this parameter uninstalls the minimum version of the module. The MinimumVerion and RequiredVersion can’t be used together in the same command.

–MaximumVersion: This module helps to uninstall the latest or the maximum version of the module. The MaximumVersion and the RequiredVersion can’t be used in the same command.

-RequiredVersion: Specifies the exact module versions to uninstall.

-AllVersions: This parameter uninstalls all the available versions of the module installed on the local computer. This parameter can’t be used with MaximumVerion, MinimumVersion, and RequiredVersion parameter.

-AllowPrerelease:  It uninstalls the module that is marked as PreRelease.

-Force: Forces to uninstall without asking for user confirmation.

-Confirm: If specified $true then it confirms for user consent and $false will not prompt the user for uninstallation and start the uninstall process.

How to use Uninstall module in PowerShell?

When the PowerShell module is installed on a computer, there is an option for the module to available for the current user or all the users. PowerShell chooses the different windows profile for them.

For the current user: “%UserProfile%\Documents\WindowsPowerShell\Modules”

For all the users: C:\program files\WindowsPowerShell\Modules

And there is another path which windows OS uses by default to store the PowerShell module when OS gets built.

OS default path for PowerShell: C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules

When we use the Uninstall-Module command, it selects the above paths to uninstall the modules from the local computer. There are some cases when multiple versions for the same module are installed because some scripters prefer to update when the new module arrives. In that case, Uninstall-Module helps to uninstall the specific version of the module using -RequiredVersion, -MinimumVersion, or -MaximumVersion command.

Sometimes the beta version of the module is also available for few users that is prerelease version and you can uninstall that specific module as well with -PreRelease parameter.

When the modules are in use or it is loaded and when you uninstall it, it will deny access, and to remediate this you need to close the open PowerShell sessions, or sometimes the system reboot may require.

Examples

Here are the follwoing examples mention below

Example #1

Uninstall ImportExcel Module.

For this example, we have the ImportExcel module installed in the local computer and we will uninstall it using the Uninstall-Module command.

Uninstall-Module ImportExcel -Verbose

Output:

PowerShell uninstall module output 1

Please note: We haven’t provided here the module version to uninstall and it doesn’t matter here if the module is for all users or the current user profile. It simply uninstalls the module.

Another way to uninstall the module is to get the module first using the Get-Module command and passing the output to the Uninstall-Module using Pipeline.

Get-Module -Name ImportExcel | Uninstall-Module -Verbose

The above command is similar to the first command.

Sometimes the module is installed in your system but not loaded in the PowerShell session then you can’t uninstall the module. For example, the ImportExcel module is installed but not loaded in PS console as shown below.

Get-Module -Name ImportExcel

PowerShell uninstall module output 2

The output is nothing but when we check, all the available modules, it shows the output.

Get-Module Importexcel -ListAvailable

Output:

PowerShell uninstall module output 3

In this case, you can either uninstall the module by first importing the module and then running uninstall command.

Get-Module -Name ImportExcel -ListAvailable | Import-Module -Verbose
Uninstall-Module ImportExcel -Force -Verbose

Or the easy method is to use the Get-InstalledModule command and Uninstall it, as shown below.

Get-InstalledModule -Name ImportExcel | Uninstall-Module -Force -Verbose

Example #2

Uninstall the Specific module version.

If we have multiple versions of the same module installed in the local system then we can use the -RequiredVersion parameter to uninstall the specific module version.

In this example, we have a 7Zip PowerShell module called “7Zip4PowerShell” installed and it has multiple versions in the same system.

Get-Module 7zip4PowerShell -ListAvailable

Output:

PowerShell uninstall module output 4

We need to uninstall the 1.5.0 module here.

Get-InstalledModule 7zip4PowerShell -RequiredVersion 1.5.0 | Uninstall-Module -Force -Verbose

Output:

PowerShell uninstall module output 5

When you check available versions for this module, you won’t find this version.

output 6

Example #3

Uninstall all the available versions of the module.

To uninstall all the available versions of the module, we can use the -AllVersions parameter.  We have a 7Zip4PowerShell module with multiple versions installed in the local computer as shown below and we need to uninstall all of them.

output 7

To uninstall all module versions,

Get-InstalledModule 7zip4PowerShell -AllVersions | Uninstall-Module -Force -Verbose

Output:

output 8

Example #4

Uninstall module with Minimum and Maximum version parameters.

When we use the -MinimumVersion parameter, the Uninstall-Module removes the highest installed version from the computer. We have the below versions installed of the 7Zip4PowerShell module.

output 9

Get-InstalledModule 7zip4PowerShell -MinimumVersion 1.5.0 | Uninstall-Module -Force -Verbose

Output:

output 10

When we use the -Maximumversion parameter, it uninstalls the Lowest version of the module.

Get-InstalledModule 7zip4PowerShell -MaximumVersion 1.5.0 | Uninstall-Module -Force -Verbose

Output:

output 11

Example #5

Uninstall module on a remote computer.

We can use the Invoke-Command module to uninstall the module from the remote server.

Invoke-Command -ComputerName LabMachine2k16 -ScriptBlock {                    Get-InstalledModule 7zip4PowerShell | Uninstall-Module -Force -Verbose}

You can use the other commands as shown in the above examples to work with the specific module version uninstall task.

Conclusion

Uninstall-Module is useful for clean-up tasks. There are many modules available in the PowerShell Gallery and you can download them for testing purposes but it also consumes disk space and many modules take time to load and also slows down PowerShell functionality and in that case Uninstall-Module helps to remove the module from the local and as well as the remote computers.

Recommended Articles

This is a guide to PowerShell uninstall module. Here we discuss How to use Uninstall module in PowerShell along with the examples and outputs. You may also have a look at the following articles to learn more –

  1. PowerShell Match
  2. PowerShell Boolean
  3. PowerShell Wait
  4. PowerShell Filter

Primary Sidebar

Footer

Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA Login

Forgot Password?

🚀 Limited Time Offer! - ENROLL NOW