Created
October 1, 2024 21:18
-
-
Save NathanTheGr8/1f4cc1c012afe118b971115138b37a03 to your computer and use it in GitHub Desktop.
taken from an old reddit post. https://www.reddit.com/r/PowerShell/comments/7d59x2/uninstall_all_but_the_latest_version_of_a_module/
This file contains 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
Get-InstalledModule | ForEach-Object { | |
$CurrentVersion = $PSItem.Version | |
Get-InstalledModule -Name $PSItem.Name -AllVersions | Where-Object -Property Version -LT -Value $CurrentVersion | |
} | Uninstall-Module -Verbose |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment