Introduction

In the world of PowerShell, some things move super fast while others may stay the same for years. If the module you are using does what you want with no issues, you may not think to see if a newer version is available. The PSReadline module is a good example. The version I was on worked great and it did what I wanted. I had no idea there was so much more that had been done.

After discovering that, I decided to see what else I had that had newer versions available. I opted to put the collected data into a PSCustomObject to make it nicer to look at and make it easier to sort.

One thing to keep in mind when looking for installed modules is that Windows PowerShell and PowerShell have separate module installs. You’ll need to run this for each.

The Script

    
        
# Get all the modules that are installed.
$Modules = Get-InstalledModule
# Create an empty array to store our results in.
$modcheck = @();
# Loop through all the modules.
foreach($mod in $Modules){
    # get the information for the latest from PSGallery.
	$PSGalleryMod = Find-Module $mod.Name;
    # Compare the installed version to the PSGallery version.
	if($PSGalleryMod.Version -ne $mod.version){
        # if they're different, put the details in a PSCustomObject.
		$modversions = [pscustomobject]@{
            Name = $($mod.name)
            InstalledVersion = $($mod.Version);InstalledPubDate =  $($mod.PublishedDate.tostring('MM/dd/yy'))
            AvailableVersion =  $($PSGalleryMod.Version)
            NewPubDate =  $($PSGalleryMod.PublishedDate.tostring('MM/dd/yy'))
        }
    # add the object to the array.
	$modcheck += $modversions;
	}
}
    

Now the contents of the $modcheck array have the modules that have newer versions available.

    
PS \>$modcheck | Format-Table

Name                                   InstalledVersion InstalledPubDate AvailableVersion NewPubDate
----                                   ---------------- ---------------- ---------------- ----------
PowerShellGet                          2.2.4.1          04/22/20         2.2.5            09/22/20
dbatools                               1.1.130          09/07/22         1.1.132          09/09/22
Microsoft.Online.SharePoint.PowerShell 16.0.21109.12000 03/16/21         16.0.22810.12000 08/29/22
SharePointCmdlets                      20.0.7654.0      01/04/21         22.0.8257.1      08/22/22
PSWriteHTML                            0.0.165          01/24/22         0.0.177          08/18/22
Pansies                                2.3.1            08/28/21         2.6.0            08/18/22
SqlServer                              21.1.18245       03/28/21         21.1.18256       07/14/21
PnP.PowerShell                         1.5.0            04/01/21         1.11.0           07/01/22
PackageManagement                      1.4.7            04/24/20         1.4.8.1          07/01/22
Get-ChildItemColor                     2.1.1            07/25/19         3.4.0            06/15/22
PSFramework                            1.4.150          09/25/20         1.7.237          06/15/22
oh-my-posh                             7.0.0            01/17/22         7.85.2           05/17/22
Pester                                 5.3.1            09/21/21         5.3.3            04/29/22
posh-git                               0.7.3            04/20/18         1.1.0            03/31/22
Microsoft.PowerShell.SecretManagement  0.5.5-preview6   11/16/20         1.1.2            01/27/22
Microsoft.PowerShell.SecretStore       0.5.4-preview4   11/16/20         1.0.6            01/27/22

Conclusion

So this is a quick and easy way to check if you have some out of date modules. Taking the list that is generated and doing some research to see if updating is needed or wanted. If there’s a big gap between what you have and what is available, go see what new features or commands there are.

Thanks for reading.
-Jeff