Download and install the newest version of specified modules from an online gallery to the local computer.

      Update-Module [[-Name] String[]] [-RequiredVersion String] [-MaximumVersion String]
         [-Credential PSCredential] [-Scope String] [-Proxy Uri] [-ProxyCredential PSCredential]
            [-Force] [-AllowPrerelease] [-AcceptLicense] [-PassThru]
               [-WhatIf] [-Confirm] [CommonParameters]

       Automatically accept the license agreement during installation if the package requires it.

       Allows you to update a module with the newer module marked as a prerelease.

       Prompt for confirmation before running Update-Module.       

       A user account that has permission to update a module.

       Force an update of each specified module without a prompt to request confirmation.
       If the module is already installed, Force reinstalls the module.

       Suppress the message that warns you when you import a cmdlet or function whose
       name includes an unapproved verb or a prohibited character.
       By default,  when a module that you import exports cmdlets or functions that have unapproved verbs in their 
       names, the PowerShell displays the following warning message:
       "Some imported command names include unapproved verbs which might make them less discoverable..."
       This message is only a warning. The complete module is still imported, including the non-conforming commands. 
       Although the message is displayed to module users, the naming problem should be fixed by the module author.
       Re-import a module and its members, even if the module or its members have an access mode of read-only.
   -MaximumVersion Version
       Specifies the maximum version of a single module to update.
       You can't add this parameter if you're attempting to update multiple modules.
       The MaximumVersion and the RequiredVersion parameters can't be used in the same command.
   -Name String[]
       The name of one or more modules to update. 
       Update-Module searches $env:PSModulePath for the modules to update.
       If no matches are found in $env:PSModulePath for the specified module name, an error occurs.

       Wildcards are accepted in module names.
       If you add wildcard characters to the specified name and no matches are found, no error occurs.

       Returns an object representing the item with which you are working.
       By default, this cmdlet does not generate any output.
       Specifies a proxy server for the request, rather than connecting directly to an internet resource.

       Specifies a user account that has permission to use the proxy server specified by the Proxy parameter.
   -RequiredVersion Version
       Specifies the exact version to which the existing installed module will be updated.
       The version specified by RequiredVersion must exist in the online gallery or an error is displayed.
       If more than one module is updated in a single command, you can't use RequiredVersion.
   -Scope String
       Specifies the installation scope of the module.
       The acceptable values for this parameter are AllUsers and CurrentUser.

       If Scope isn't specified, the update is installed in the CurrentUser scope.
       The AllUsers scope requires elevated permissions and installs modules in a location that is accessible to
       all users of the computer: 

       The CurrentUser doesn't require elevated permissions and installs modules in a location that is accessible
       only to the current user of the computer:

        When no Scope is defined, the default is set based on the PowerShellGet version.
        In PowerShellGet versions 2.0.0 and above, the default is CurrentUser, which does not require elevation
        for install. In PowerShellGet 1.x versions, the default is AllUsers, which requires elevation for install.

        Show what would happen if the cmdlet were run. The cmdlet isn't run.

Standard Aliases for Update-Module: none

For PowerShell version 6.0 and above, the default installation scope is always CurrentUser. Module updates for CurrentUser, $home\Documents\PowerShell\Modules, don't need elevated permissions. Module updates for AllUsers, $env:ProgramFiles\PowerShell\Modules, need elevated permissions.

As of April 2020, the PowerShell Gallery no longer supports Transport Layer Security (TLS) versions 1.0 and 1.1. If you are not using TLS 1.2 or higher, you will receive an error when trying to access the PowerShell Gallery. Use the following command to ensure you are using TLS 1.2:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

For more information, see the announcement in the PowerShell blog.

Update-Module runs on PowerShell 3.0 or later releases of PowerShell, on Windows 7 or Windows 2008 R2 and later releases of Windows.

You can only run Update-Module on modules that you installed from the online gallery by running Install-Module. If the module that you specify with the -Name parameter wasn't installed by using Install-Module, an error occurs.

Some modules such as PSReadLine are shipped with Windows and therefore cannot be updated, performing a fresh install with Install-Module -Scope CurrentUser -Force will create a copy in the current user's scope which may then be updated using Update-Module.

If Update-Module attempts to update binaries that are in use, Update-Module returns an error that identifies the problem processes. The user is informed to retry Update-Module after the processes are stopped.

PowerShellGet is an in-box module in Windows 10 or newer, Windows Server 2016 or newer, (WMF) 5.0 or newer, PowerShell 6.


Update all modules:

PS C:\> Update-Module

Update a module by name:

PS C:\> Update-Module -Name SpeculationControl

View what-if Update-Module runs:

PS C:\> Update-Module -WhatIf
What if: Performing the operation "Update-Module" on target "Version '2.8.0' of module 'Carbon',   updating to version '2.8.1'".
What if: Performing the operation "Update-Module" on target "Version '1.0.10' of module   'SpeculationControl', updating to version '1.0.14'".

Update a module to a specified version. The version must exist in the online gallery or an error is displayed.:

PS C:\> Update-Module -Name SpeculationControl -RequiredVersion 1.0.14

Update a module without confirmation. If the module is already installed, the Force parameter reinstalls the module:

PS C:\> Update-Module -Name SpeculationControl -Force

“Most imports are from outside of the country” ~ George W. Bush

Related PowerShell Cmdlets

Find-Module - Find modules from an online gallery
Get-Module - Get the modules imported to the session.
Get-InstalledModule - Get installed modules on a computer
Import-Module - Add a module to the session.
Install-Module - Download and install modules from an online repository.
New-Module - Create a new dynamic module (only in memory) .
Remove-Module - Remove a module from the current session.
Export-ModuleMember - Export specific module members.

Copyright © 1999-2023 SS64.com
Some rights reserved