EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 360+ Courses All in One Bundle
  • Login

PowerShell uninstall module

Secondary Sidebar
PowerShell Tutorial
  • Basics
    • PowerShell Restart Service
    • PowerShell comment
    • PowerShell Map Network Drive
    • PowerShell Append to File
    • PowerShell print
    • What is PowerShell
    • Uses Of Powershell
    • PowerShell Empire
    • PowerShell Parameter
    • PowerShell Stop Service
    • PowerShell Versions
    • How To Install PowerShell
    • PowerShell uninstall module
    • How to Use PowerShell?
    • PowerShell Logging
    • PowerShell Tools
    • PowerShell Commands
    • PowerShell Version Command
    • PowerShell Administrator
    • PowerShell Modules
    • PowerShell Registry
    • PowerShell block Comment
    • PowerShell Verbs
    • PowerShell list
    • PowerShell add user to group
    • PowerShell Write to Console
    • Variable in PowerShell
    • PowerShell New Line
    • PowerShell prompt for input
    • PowerShell File Extension
    • Powershell Remotesigned
    • PowerShell Write to File
    • PowerShell Ping
    • PowerShell wget
    • PowerShell Global variable
    • PowerShell Get-ADGroup
    • Array in PowerShell
    • PowerShell Multidimensional Array
    • PowerShell Array of Strings
    • PowerShell? join array
    • Useful PowerShell Scripts
    • String in PowerShell
    • PowerShell Switch Statement
    • PowerShell Function Parameters
    • PowerShell vs PowerShell ISE
    • PowerShell test-connection
    • PowerShell Test-NetConnection
    • PowerShell GUI
    • PowerShell Variable in String
    • PowerShell Active Directory
  • Variables
    • PowerShell Variables
    • PowerShell Environment Variables
    • PowerShell set environment variable
    • Hashtable in PowerShell
    • Set Variable in PowerShell
  • Operators
    • PowerShell Operators
    • Comparison Operators in PowerShell
    • Logical Operators in PowerShell
    • PowerShell Boolean
    • PowerShell Like Operator
  • cmdlet
    • PowerShell Wait
    • PowerShell Match
    • cmdlets in PowerShell
    • Start PowerShell from cmd
    • Add-Content in PowerShell
    • Get Help in PowerShell
    • PowerShell Copy-Item
    • PowerShell Remove-Item
    • PowerShell Move-Item
    • Get Command in PowerShell
    • PowerShell Run Command
    • Windows PowerShell ISE
    • Windows Powershell Commands
    • WinRM PowerShell
    • PowerShell Date
    • Powershell Write-Host
    • PowerShell Get-ChildItem
    • PowerShell Sort-Object
    • PowerShell Where Object
    • PowerShell Set-Content
    • PowerShell Set-Location
    • PowerShell Invoke-Command
    • PowerShell Invoke-Webrequest
    • PowerShell Get-Location
    • PowerShell Get-Date
    • PowerShell Get-Service
    • PowerShell Test-Path
    • Powershell Module Path
    • PowerShell Out-File
    • PowerShell if File Exists
    • Powershell Copy File
    • PowerShell Delete File
    • PowerShell New-Item
    • PowerShell Rename-Item
    • PowerShell ComputerName
    • PowerShell Get-Content
    • PowerShell Get-Item
    • PowerShell Get-ADUser
    • PowerShell Grep
    • PowerShell Concatenate String
    • PowerShell Get-Process
    • PowerShell Count
    • PowerShell pause
  • Control Statements
    • If Statement in PowerShell
    • If Else in PowerShell
    • Else If in PowerShell
    • Loops in PowerShell
    • For loop in PowerShell
    • PowerShell While Loop
    • PowerShell do while
    • PowerShell Loop through Array
    • PowerShell add to array
    • PowerShell ForEach Loop
    • PowerShell Break
    • PowerShell Continue
    • Switch Case in PowerShell
    • PowerShell If-Not
    • Try-catch in PowerShell
  • Functions
    • PowerShell Functions
    • PowerShell String Functions
    • powershell nslookup
    • PowerShell here string
    • PowerShell Wildcards
    • Regex in PowerShell
    • PowerShell not like
    • PowerShell Filter
    • PowerShell Sleep
    • PowerShell where
    • PowerShell join string
    • PowerShell Exit
    • PowerShell null
    • PowerShell Dictionary
    • PowerShell Location
    • PowerShell Start-Service
    • PowerShell is not digitally signed
    • PowerShell Uptime
    • PowerShell Create Directory
    • PowerShell Trim
    • PowerShell Join-Path
    • PowerShell Execution Policy
    • PowerShell SubString
    • PowerShell Format Table
    • PowerShell Import Module
    • PowerShell ForEach Object
    • PowerShell Alias
    • PowerShell Scheduled Task
    • PowerShell Convert String to Date
    • PowerShell Split String
    • PowerShell Multiline String
    • PowerShell MultiLine Comment
    • PowerShell Rename Folder
    • PowerShell Delete Folder
    • PowerShell String Replace
    • PowerShell join
    • PowerShell xcopy
    • PowerShell Base64
    • PowerShell Tail
    • PowerShell User List
    • PowerShell remove User from group
    • PowerShell JSON Format
    • PowerShell Send Mail
    • PowerShell Convert to String
    • PowerShell Start-Process
    • PowerShell change directory
    • PowerShell Open File
    • PowerShell Batch File
    • PowerShell ZIP
    • PowerShell unzip
    • PowerShell XML
    • PowerShell XML Parsing
    • Remote PowerShell
    • PowerShell Escape Character
    • PowerShell scriptblock
    • PowerShell Executable Location
    • PowerShell Import-CSV?
    • PowerShell Export CSV
  • Interview Questions
    • PowerShell Interview Questions

Related Courses

Shell Scripting Course

All in One Data Science Courses

Data Visualization Courses

Home Data Science Data Science Tutorials PowerShell Tutorial PowerShell uninstall module

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.

All in One Data Science Bundle(360+ Courses, 50+ projects)
Python TutorialMachine LearningAWSArtificial Intelligence
TableauR ProgrammingPowerBIDeep Learning
Price
View Courses
360+ Online Courses | 50+ projects | 1500+ Hours | Verifiable Certificates | Lifetime Access
4.7 (85,992 ratings)

Syntax

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

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
Popular Course in this category
PowerShell Training (2 Courses, 1 Project)
  2 Online Courses |  1 Hands-on Project |   4+ Hours |  Verifiable Certificate of Completion
4.5
Price

View Course

Related Courses

Shell Scripting Training (4 Courses, 1 Project)4.9
All in One Data Science Bundle (360+ Courses, 50+ projects)4.8
Data Visualization Training (15 Courses, 5+ Projects)4.7
0 Shares
Share
Tweet
Share
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Database Management
  • Machine Learning
  • All Tutorials
Certification Courses
  • All Courses
  • Data Science Course - All in One Bundle
  • Machine Learning Course
  • Hadoop Certification Training
  • Cloud Computing Training Course
  • R Programming Course
  • AWS Training Course
  • SAS Training Course

ISO 10004:2018 & ISO 9001:2015 Certified

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

EDUCBA
Free Data Science Course

SPSS, Data visualization with Python, Matplotlib Library, Seaborn Package

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

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

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

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

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

By signing up, you agree to our Terms of Use and Privacy Policy.

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

Special Offer - PowerShell Training (2 Courses, 1 Project) Learn More