Update Module - PowerShell
Overview
Update-Module is a PowerShell command that checks for available updates for installed PowerShell modules and installs them if available. It enables users to maintain up-to-date modules, ensuring access to the latest features and security patches.
Syntax
Update-Module [-Name] <string[]> [-Repository <string[]>]
[-Force] [-WhatIf] [-Confirm] [-ThrottleLimit <int>] [-Credential <PSCredential>]
[-Verbose] [-Debug] [-ErrorAction <ActionPreference>]
[-ErrorVariable <string>] [-OutVariable <string>]
[-OutBuffer <bool>]
Options/Flags
- -Name: Specifies the name(s) of the modules to update. Supports wildcards and accepts multiple values.
 - -Repository: Updates modules from the specified repository(ies). Supports multiple values.
 - -Force: Suppresses confirmation prompts and forces module installation.
 - -WhatIf: Performs a simulation of the command without actually updating any modules.
 - -Confirm: Prompts for confirmation before updating modules.
 - -ThrottleLimit: Sets the maximum number of concurrent module updates.
 - -Credential: Specifies the credentials to use when accessing a private repository.
 - -Verbose: Outputs detailed progress information during module update.
 - -Debug: Outputs diagnostic information, useful for troubleshooting.
 - -ErrorAction: Specifies the action to take when an error occurs.
 - -ErrorVariable: Stores the error object(s) in the specified variable for later handling.
 - -OutVariable: Stores the updated module objects in the specified variable.
 - -OutBuffer: Buffers all output to the specified variable, enabling its later retrieval in a single object.
 
Examples
Simple module update:
Update-Module -Name PSReadLine
Update multiple modules from a specific repository:
Update-Module -Name PSReadLine,PSSession -Repository PSGallery
Force installation without confirmation:
Update-Module -Name SomeModule -Force
Simulate command without updating:
Update-Module -WhatIf -Name SomeModule
Common Issues
- “The specified module is not installed”: Ensure the module is installed before updating.
 - “Access denied”: Use -Credential to provide credentials when accessing private repositories.
 - “Update operation failed”: Check network connectivity and firewall settings. Re-run the command or contact the repository owner for assistance.
 
Integration
Combining with Install-Module:
Install-Module -Name ModuleA | Update-Module
Using with Script Blocks:
$modules = Get-Module -ListAvailable
Update-Module $modules | Where-Object { $_.Updated }
Related Commands
- Get-Module: Lists installed PowerShell modules.
 - Install-Module: Installs new PowerShell modules.
 - Remove-Module: Uninstalls PowerShell modules.