Created
June 6, 2025 09:52
-
-
Save fslef/854430dd087304d13582819cf1a64d48 to your computer and use it in GitHub Desktop.
Remove old Powershell Modules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $Latest = Get-InstalledModule | |
| foreach ($module in $Latest) { | |
| Write-Verbose -Message "Uninstalling old versions of $($module.Name) [latest is $( $module.Version)]" -Verbose | |
| Get-InstalledModule -Name $module.Name -AllVersions | Where-Object {$_.Version -ne $module.Version} | Uninstall-Module -Verbose -force | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment