Skip to content

Instantly share code, notes, and snippets.

@kekoa-
Created September 24, 2019 23:07
Show Gist options
  • Select an option

  • Save kekoa-/f9e199284f3b3c6ddba673dc84cfa3f1 to your computer and use it in GitHub Desktop.

Select an option

Save kekoa-/f9e199284f3b3c6ddba673dc84cfa3f1 to your computer and use it in GitHub Desktop.
Returns installed modules and uses color to indicate when multiple versions are installed Source: http://sharepointjack.com/2017/powershell-script-to-remove-duplicate-old-modules/
# See what modules are installed -- lists multiple versions too
# Source: http://sharepointjack.com/2017/powershell-script-to-remove-duplicate-old-modules/
Write-Host "this will report all modules with duplicate (older and newer) versions installed"
Write-Host "be sure to run this as an admin" -foregroundcolor yellow
Write-Host "(You can update all your Azure RMmodules with update-module Azurerm -force)"
$mods = Get-InstalledModule
foreach ($Mod in $mods) {
Write-Host "Checking $($mod.name)"
$latest = Get-InstalledModule $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