{"id":11204,"date":"2026-01-13T12:00:57","date_gmt":"2026-01-13T12:00:57","guid":{"rendered":"https:\/\/cheapwindowsvps.com\/blog\/a-step-by-step-guide-to-removing-unused-powershell-modules\/"},"modified":"2026-01-13T12:00:57","modified_gmt":"2026-01-13T12:00:57","slug":"a-step-by-step-guide-to-removing-unused-powershell-modules","status":"publish","type":"post","link":"https:\/\/cheapwindowsvps.com\/blog\/a-step-by-step-guide-to-removing-unused-powershell-modules\/","title":{"rendered":"A Step-by-Step Guide to Removing Unused PowerShell Modules"},"content":{"rendered":"<p>To remove old or unused PowerShell modules from your Windows computer, you can follow these straightforward steps. These actions may help to resolve issues like slow startup times in PowerShell or conflicts between different modules.<\/p>\n<h3>Listing Installed Modules<\/h3>\n<p>First, to see which third-party PowerShell modules are installed, you can use the following command:<\/p>\n<pre><code class=\"language-powershell\">Get-InstalledModule<\/code><\/pre>\n<p>This command shows all third-party modules registered via the <code>Install-Module<\/code> cmdlet. For instance, if all are installed through the PSGallery repository, they will be listed here.<\/p>\n<h3>Uninstalling a Module<\/h3>\n<p>To remove a specific module, use the <code>Uninstall-Module<\/code> command followed by the module name. For example:<\/p>\n<pre><code class=\"language-powershell\">Uninstall-Module -Name PSWindowsUpdate<\/code><\/pre>\n<p>If multiple versions of the module exist, this command will remove the most recent version or will fail if multiple versions are detected. To view all installed versions of a module, use:<\/p>\n<pre><code class=\"language-powershell\">Get-Module pswindowsupdate -ListAvailable<\/code><\/pre>\n<p>To uninstall a particular version, you can specify it like this:<\/p>\n<pre><code class=\"language-powershell\">Uninstall-Module -Name PSWindowsUpdate -RequiredVersion 2.2.1.4 -Verbose<\/code><\/pre>\n<p>If you want to keep only the latest version of a module, you can run:<\/p>\n<pre><code class=\"language-powershell\">$moduleName = &quot;PSWindowsUpdate&quot;$versions = Get-InstalledModule -Name $moduleName -AllVersions | Sort-Object Version -Descending$versions | Select-Object -Skip 1 | ForEach-Object { Uninstall-Module -Name $moduleName -RequiredVersion $_.Version -Force }<\/code><\/pre>\n<p>To remove all versions of a module, the command is:<\/p>\n<pre><code class=\"language-powershell\">Uninstall-Module -Name PSWindowsUpdate -AllVersions<\/code><\/pre>\n<h3>Uninstalling on a Remote Computer<\/h3>\n<p>You can also uninstall a module from a remote machine using <code>Invoke-Command<\/code>:<\/p>\n<pre><code class=\"language-powershell\">Invoke-Command -ComputerName mun-dc01 -ScriptBlock {Uninstall-Module PSWindowsUpdate -RequiredVersion 2.2.1.2 -Force -Verbose}<\/code><\/pre>\n<h3>Handling Errors During Uninstallation<\/h3>\n<p>Sometimes, you might encounter an error that indicates the module is in use, such as:<\/p>\n<pre><code>WARNING: The version '2.2.1.4' of module 'PSWindowsUpdate' is currently in use. Retry the operation after closing the applications.<\/code><\/pre>\n<p>To resolve this, you need to close the PowerShell session where the module is loaded. You can list currently loaded modules with:<\/p>\n<pre><code class=\"language-powershell\">Get-Module<\/code><\/pre>\n<p>To unload a module from memory without exiting the console, use:<\/p>\n<pre><code class=\"language-powershell\">Remove-Module -Name PSWindowsUpdate<\/code><\/pre>\n<p>After this, try removing the module again with:<\/p>\n<pre><code class=\"language-powershell\">Uninstall-Module -Name PSWindowsUpdate -Force<\/code><\/pre>\n<h3>Bypassing Automatic Module Loading<\/h3>\n<p>If a module loads automatically at the start of a PowerShell session, you can bypass this by launching PowerShell with the <code>-NoProfile<\/code> option:<\/p>\n<pre><code class=\"language-powershell\">Powershell.exe -NoProfile -Command &quot;Uninstall-Module ImportExcel&quot;<\/code><\/pre>\n<h3>Viewing All Available Modules<\/h3>\n<p>To check all modules on your computer, including those manually installed, run:<\/p>\n<pre><code class=\"language-powershell\">Get-Module -ListAvailable | Select-Object Name, Version, Path<\/code><\/pre>\n<p>This will show you where the module files are located. Standard paths for installed modules include:<\/p>\n<pre><code>C:Users%username%DocumentsWindowsPowerShellModulesC:Program FilesWindowsPowerShellModulesC:Windowssystem32WindowsPowerShellv1.0Modules<\/code><\/pre>\n<p>For PowerShell Core 7.x, you\u2019ll have additional paths:<\/p>\n<pre><code>C:Program FilesPowerShellModules<\/code><\/pre>\n<h3>Cleaning Up Residual Files<\/h3>\n<p>Even after uninstalling a module, some files may remain. You can manually delete these leftover files. A simple PowerShell script can do this:<\/p>\n<pre><code class=\"language-powershell\">$Module = Get-Module ImportExcel -ListAvailableUninstall-Module $Module.Name -VerboseRemove-Item $Module.ModuleBase -Recurse -Force<\/code><\/pre>\n<p>With these steps, you should be able to effectively manage and remove any old or unused PowerShell modules from your system.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To remove old or unused PowerShell modules from your Windows computer, you can follow these straightforward steps. These actions may help to resolve issues like slow startup times in PowerShell or conflicts between different modules. Listing Installed Modules First, to see which third-party PowerShell modules are installed, you can use the following command: Get-InstalledModule This [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":11205,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[117],"tags":[],"class_list":["post-11204","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"_links":{"self":[{"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/posts\/11204","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/comments?post=11204"}],"version-history":[{"count":0,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/posts\/11204\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/media\/11205"}],"wp:attachment":[{"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/media?parent=11204"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/categories?post=11204"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/tags?post=11204"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}