A Spectre patch check on our Austin office PCs kept giving stale answers, and the cause was an old module. Update-Module in PowerShell pulls the newest version of a module you installed from the PowerShell Gallery:
Update-Module -Name SpeculationControl -Force
In this tutorial, I’ll show you how Update-Module in PowerShell really behaves: checking for updates, pinning versions, updating everything, cleaning up old copies and the errors you’ll hit.
My test module was SpeculationControl, a small Microsoft module, starting at version 1.0.17 in the CurrentUser scope. I ran everything in PowerShell 7.6 and 5.1.
To keep test runs fast, I served its gallery packages from a local folder repository (more on that below).
How to Check for PowerShell Module Updates First
Get-InstalledModule tells you which version you have, and Find-Module asks the module’s repository for the newest one. Compare them before you update anything:
$installed = Get-InstalledModule -Name SpeculationControl
$latest = Find-Module -Name SpeculationControl -Repository $installed.Repository
[pscustomobject]@{
Name = $installed.Name
Installed = $installed.Version
Latest = $latest.Version
Update = [version]$latest.Version -gt [version]$installed.Version
} | Format-Table
Output:
Name Installed Latest Update
---- --------- ------ ------
SpeculationControl 1.0.17 1.0.19 True

-Repository keeps Find-Module on the module’s own source instead of every registered repository.
Cast with [version], because Get-InstalledModule returns a String in PowerShell 7 and a System.Version in 5.1:
(Get-InstalledModule -Name SpeculationControl).Version.GetType().Name
Output:
String
As text, ‘1.0.9’ sorts after ‘1.0.19’, so always cast before you compare. Get-InstalledModule only sees Install-Module installs, so list the installed modules with Get-Module -ListAvailable when you need the full picture.
Update a Module With Update-Module
Name the module, and Update-Module installs the newest version from its repository. I added -Force because PSGallery is untrusted by default, and my test repository is too:
Update-Module -Name SpeculationControl -Force
Get-InstalledModule -Name SpeculationControl -AllVersions |
Format-Table Name, Version
Output:
Name Version
---- -------
SpeculationControl 1.0.17
SpeculationControl 1.0.19

Without -Force, a script with no console just printed “WARNING: User declined to install module”.
Both shells kept 1.0.17 next to th