It seems to me that the topic of finding or detecting module updates on the PowerShell Gallery has gotten a lot of interest over the last few days. So I thought I’d contribute my bit of code to check currently installed modules against their online versions in the PowerShell Gallery.
I have a PowerShell script I called Check-ModuleUpdate, which you can find as a gist on Github.
The script gets all currently installed scripts and filters out those that do not have a value for the RepositorySourceLocation. On my computer I’ve only installed from the PSGallery so the links are all the same. If you will have multiple locations you’ll need to modify the code, especially with Find-Module to accommodate the differences.
The script then uses a ForEach loop to get the online version so that it can compare it with the installed version. The script writes a custom object to the pipeline. I’ve also included code to indicate if you have multiple versions of a module installed.
Another use is to pipe to Out-Gridview and use that as an object picker to update selected modules.
Out-Gridview -title "Select modules to update" -PassThru |
Write-Host "Updating $($_.name)" -foreground Cyan
update-module $_.name -force
I’ll admit this isn’t a perfect script. You might even prefer to have it as a function. So I’ll leave enhancements and updates to you.