Skip to content

Instantly share code, notes, and snippets.

@Splaxi
Last active November 29, 2018 11:16
Show Gist options
  • Select an option

  • Save Splaxi/305315ca67750e043b42498da40ba972 to your computer and use it in GitHub Desktop.

Select an option

Save Splaxi/305315ca67750e043b42498da40ba972 to your computer and use it in GitHub Desktop.
Test all modules for multiple installed versions
#Copy & pasted from the work of Jack (@sharepointjack) - http://sharepointjack.com/2017/powershell-script-to-remove-duplicate-old-modules
#Will test all installed modules for multiple versions installed on the machine
$mods = Get-InstalledModule
foreach ($Mod in $mods) {
Write-Host "Checking $($mod.name)"
$latest = Find-Module $mod.name
$specificmods = Get-InstalledModule $mod.name -allversions
Write-Host "$($specificmods.count) versions of this module found [ $($mod.name) ]"
foreach ($sm in $specificmods) {
if ($sm.version -eq $latest.version)
{ $color = "green"}
else
{ $color = "magenta"}
Write-Host " $($sm.name) - $($sm.version) [highest installed is $($latest.version)]" -foregroundcolor $color
}
Write-Host "------------------------"
}
Write-Host "Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment