Skip Ribbon Commands
Skip to main content

Quick Launch

Todd Klindt's home page > Todd Klindt's Office 365 Admin Blog > Posts > PowerShell to Update your PowerShell Modules
May 10
PowerShell to Update your PowerShell Modules

One of the great things about PowerShell is how easy it is to extend it with modules. The only thing greater is all the modules that are out there. I have a bunch that I use on a daily basis, I couldn’t live without them. But in today’s rapid development cycle it’s easy to get behind on your favorite modules. I wrote this blog post to help people keep up with the Office 365 related PowerShell modules I use, but from what I understand there are other technologies out there with their own suite of modules that people want to keep up with. To help those folks out, I thought I’d share how I keep up to date with my favorite modules.

This method only works with modules that are installed from a repository. If a module has been installed some other way, like with an MSI or EXE you’re out of luck.

The key to this magic is a group of cmdlets that deal with modules, particularly Find-Module and Update-Module. That’s why it only works with modules installed from a repository with Install-Module. To find the relevant cmdlets run:

Get-Command -Noun module


Get-Command -Noun InstalledModule

Here’s how I stitch them together to get a list of modules that have updates:

     Get-InstalledModule | foreach { $b = (find-module $ ; if ($b -ne $_.version) { Write-host "$($ has an update from $($_.version) to $b" } }

Let’s break that down.


Gets all of the modules that have been installed from a repository.

| foreach

Pipes them all l through a foreach loop.

$b = (find-module $

Grabs the current published version of the module in the loop.

if ($b -ne $_.version)

Checks to see if the published version is the same as the Version property of the installed module.

{ Write-host "$($ has an update from $($_.version) to $b" }

If they are not equal, it writes out the module name, the installed version, and the current published version.

It looks like this:


In screenshot I ran Get-InstalledModule to show its full output, then the full command and its output.

Now we know which modules can be updated. We can update an individual module like this:

Update-Module SharePointPnPPowerShellOnline –Force

That will update the SharePointPnPPowerShellOnline module and won’t yell at us because it’s replacing an existing one. If the module has been installed with the “AllUsers” scope (the default) you’ll need to run the Update-Module cmdlet in an Administrator prompt.


Now if I run my command it will not report that that the SharePointPnPPowerShellOnline module has an update.


It would be easy to replace the “Write-Host…” part of the command with “Update-Module $” and have it update them automatically. I didn’t do that mainly because the PowerApps modules’ install is a little hinky and requires some extra handholding. If you don’t have them installed, or you want to upgrade them manually first, you could have the command update them automatically.

I hope you’ve found this helpful.




Thanks for putting this together!

Very handy.
 on 5/29/2019 11:04 PM

An alternative

I wrote a function called Compare-Module in my PSScriptTools module which you can download from the PowerShell Gallery.

It should simplify this process.
 on 7/9/2019 1:50 PM

Re: An alternative

Thanks, Jeff. That's helpful.

Todd O. KlindtNo presence information on 7/9/2019 1:52 PM


it's truly wonderful weblog. it's realy educational along with a this type of great work. i really like this particular. kitchen remodel contractor
 on 11/12/2023 8:06 AM


Really good write-up, Appreciate it intended for giving That expertise. Excellently published document, but only if many blog writers made available identical higher level of information since you, the online world is a significantly better area. You need to thanks! birds that lay blue eggs
 on 12/5/2023 7:38 AM


Keep up the great work, I read few posts on this website and I think that your web blog is real interesting and has got sectors of fantastic information. mdpv online
 on 12/9/2023 3:48 AM


Thanks for another wonderful post. Where else could anybody get that type of info in such an ideal way of writing? Movers and packers in Gurgaon
 on 12/9/2023 6:51 AM


Like a Beginner, I'm completely discovering on the internet with regard to content articles that may be associated with help me personally. login
 on 12/28/2023 7:38 AM


Thanks for sharing the post.. parents are worlds best person in each lives of individual..they need or must succeed to sustain needs of the family. ドイツ市民のためのカナダビザドイツ市民のためのカナダビザ/
 on 2/10/2024 6:06 AM

Add Comment

Items on this list require content approval. Your submission will not appear in public views until approved by someone with proper rights. More information on content approval.


Body *

Today's date *

Select a date from the calendar.
Please enter today's date so I know you are a real person


Want a message when I reply to your comment? Put your Twitter handle here.