Whenever you install new modules via Install-Module or update existing modules via Update-Module, new module versions are installed side-by-side.
If you always work with the latest versions of modules and do not need to access a specific older version, you might want to find outdated modules and remove them:
# get all installed modules as a hash table
# each key holds all versions of a given module
$list = Get-InstalledModule |
Get-InstalledModule -AllVersions |
Group-Object -Property Name -AsHashTable -AsString
# take all module names...
# dump all present versions...
# sort by version descending (newest first)
Sort-Object -Property Version -Descending |
# and skip newest, returning all other
Select-Object -Skip 1
# remove outdated (check whether you really don't need them anymore)
ReTweet this Tip!
Powered by IDERA