Created
November 29, 2018 11:01
-
-
Save Splaxi/7f01062cca8acaec0f0bb9443f2a8fdd to your computer and use it in GitHub Desktop.
Test all modules versions against PSGallery
This file contains hidden or 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
| #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