How to uninstall the PowerShell Module?


To uninstall the PowerShell module, we can directly use the Uninstall-Module command but the module should not be in use, otherwise, it will throw an error.

When we use the Uninstall-Module command, it can uninstall the module from the current user profile or from the all users profile.

Uninstall-Module 7Zip4PowerShell -Force -Verbose

Another method,

Get-InstalledModule 7Zip4Powershell | Uninstall-Module -Force -Verbose

If you have multiple versions of the same module installed in the PowerShell, and if you want to uninstall all of them then use the -AllVersions Parameter.

Uninstall-Module 7Zip4PowerShell -AllVersions -Force -Verbose

If you want to uninstall the specific version, we can use -RequiredVersion.

Uninstall-Module 7Zip4PowerShell -RequiredVersion 1.5.0 -Force -Verbose

To uninstall on the remote computer, use the Invoke-Command method.

Invoke-Command -ComputerName RemoteComputer1 -ScriptBlock {
   Uninstall-Module 7Zip4PowerShell -RequiredVersion 1.5.0 -Force -Verbose
}

Updated on: 18-Mar-2021

16K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements