To update all PowerShell modules installed from registered online repositories, filter the modules found in PSModulePath and pass them to Update-Module. Preview the operation first on production systems.
Use the following PowerShell one-liner to update all modules that were installed from an online repository:
Get-Module -ListAvailable | Where-Object RepositorySourceLocation -ne $null | Update-Module -Force -Confirm:$false
How the command works
Get-Module -ListAvailablefinds modules installed in the locations listed in$env:PSModulePath.Where-Object RepositorySourceLocation -ne $nullkeeps modules associated with an online repository, excluding most built-in and manually copied modules.Update-Moduledownloads and installs the latest stable version available from the registered repository.-Forcesuppresses the normal confirmation and can reinstall a version that is already present.-Confirm:$falseprevents interactive confirmation prompts, which is useful in scripts and scheduled maintenance.
Preview updates before installing them
Replace the last part of the command with Update-Module -WhatIf to preview the proposed changes:
Get-Module -ListAvailable | Where-Object RepositorySourceLocation -ne $null | Update-Module -WhatIf
Requirements and limitations
- Use the same user or administrator context that installed the modules.
- Built-in and manually copied modules are not updated by
Update-Module. - Close sessions actively using a module if its files cannot be replaced.
Microsoft documents supported behavior in the Update-Module reference. After testing new versions, follow the old-module cleanup guide.

Comments