Last active
December 6, 2023 00:46
-
-
Save Froosh/80bf931d1fe851d0fb2a8d980fd3b704 to your computer and use it in GitHub Desktop.
Remove old modules, useful for after a few Az or Microsoft.Graph metamodule upgrades
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-InstalledPSResource -Scope CurrentUser | | |
Group-Object -Property Name | | |
ForEach-Object -Process { | |
$VersionsToRemove = $PSItem.Group | Sort-Object -Property Version -Descending | Select-Object -Skip 1 | |
foreach ($Version in $VersionsToRemove) { | |
Uninstall-PSResource -Verbose -Name $Version.Name -Version $Version.Version -SkipDependencyCheck | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment