Skip to content

Instantly share code, notes, and snippets.

@Splaxi
Created November 29, 2018 11:01
Show Gist options
  • Select an option

  • Save Splaxi/7f01062cca8acaec0f0bb9443f2a8fdd to your computer and use it in GitHub Desktop.

Select an option

Save Splaxi/7f01062cca8acaec0f0bb9443f2a8fdd to your computer and use it in GitHub Desktop.
Test all modules versions against PSGallery
#Inspired from the work of Jack (@sharepointjack) - http://sharepointjack.com/2017/powershell-script-to-remove-duplicate-old-modules
#Will test all installed modules against the PSGallery and see if a never version is available
$mods = Get-InstalledModule
foreach ($mod in $mods) {
Write-Host "Checking $($mod.name)"
$latestAvailable = Find-Module $mod.Name -ErrorAction SilentlyContinue
if($null -eq $latestAvailable) { continue }
if ($mod.version -eq $latestAvailable.version) {
$color = "green"
$text = "Latest available version match current installed"
}
else {
$color = "magenta"
$text = "Latest available version is higher than the current installed"
}
Write-Host "$($mod.Name) - $($mod.version) [$text $($latestAvailable.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