Skip to content
PowerShell Commands

Update-Module

Update-Module [[-Name] <String[]>] [-Confirm] [-Credential <PSCredential>] [-Force] [-MaximumVersion <Version>][-Proxy <Uri>] [-ProxyCredential <PSCredential>] [-RequiredVersion <Version>] [-WhatIf] [<CommonParameters>]

The Update-Module cmdlet installs a newer version of a Windows PowerShell module that was installed from the online gallery by running Install-Module on the local computer.

By default, the newest version of the specified module available in online gallery is installed, unless you specify a required version. You can update an existing, installed module by specifying the name of the module; Update-Module searches $env:PSModulePath for the module that you want to update.

Running Update-Module without the Name parameter updates all modules that can be updated on the local computer.

Parameters

-Confirm [<SwitchParameter>]

  • Default value is False
  • Accepts pipeline input False

Prompts you for confirmation before running the cmdlet.

-Credential <PSCredential>

  • Default value is None
  • Accepts pipeline input ByPropertyName

@{Text=}

-Force [<SwitchParameter>]

  • Default value is False
  • Accepts pipeline input False

Forces the update of each specified module, regardless of the current version of the module installed.

-MaximumVersion <Version>

  • Default value is None
  • Accepts pipeline input ByPropertyName

Specifies the maximum version of a single module to update. You cannot add this parameter if you are attempting to update multiple modules. The MaximumVersion and the RequiredVersion parameters are mutually exclusive; you cannot use both parameters in the same command.

-Name <String[]>

  • Default value is None
  • Accepts pipeline input ByPropertyName

Specifies the names of one or more modules to be updated. Update-Module searches $env:PSModulePath for the modules to update. Without wildcard characters, the only modules that are updated are those that exactly match specified names. If no matches are found for the specified modules in $env:PSModulePath, an error occurs. If you add wildcard characters to the name that you specify, but no matches are found, no error occurs.

-Proxy <Uri>

  • Default value is None
  • Accepts pipeline input ByPropertyName

@{Text=}

-ProxyCredential <PSCredential>

  • Default value is None
  • Accepts pipeline input ByPropertyName

@{Text=}

-RequiredVersion <Version>

  • Default value is None
  • Accepts pipeline input ByPropertyName

Specifies the exact version to which the existing installed module will be updated. You cannot add this parameter if you are updating more than one module in a single command. If the online gallery does not have this version of the specified module, an error occurs.

-WhatIf [<SwitchParameter>]

  • Default value is False
  • Accepts pipeline input False

Shows what would happen if the cmdlet runs. The cmdlet is not run.

<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,ErrorAction, ErrorVariable, WarningAction, WarningVariable,OutBuffer, PipelineVariable, and OutVariable.

Examples
  1. Update all modules:
    PS C:\> Update-Module
    

    This example updates to the newest version all modules in $env:PSModulePath that were installed by Install-Module from the online gallery.

  2. Update a module by name:
    PS C:\> Update-Module -Name "MyDscModule"
    

    This example updates to the newest online gallery version the first module named MyDscModule found in $env:PSModulePath. If the existing MyDscModule is already the newest version, nothing happens. If Update-Module cannot find a module named MyDscModule in $env:PSModulePath, an error occurs.

  3. View what would occur if Update-Module runs:
    PS C:\> Update-Module -WhatIf
    What if: Performing the operation "Update-Module" on target "Version '2.0' of module 'xDscDiagnostics', updating to version '2.0'".
    What if: Performing the operation "Update-Module" on target "Version '1.1.1' of module 'xDSCResourceDesigner', updating to version '1.1.1.1'".
    

    This example shows what modules would be updated, and to which versions, if the Update-Module command were actually run. The command is not run.

  4. Update a module to a specified version:
    PS C:\> Update-Module -Name "ContosoModule" -RequiredVersion 2.1.0.3
    

    This example updates ContosoModule to version 2.1.0.3. If version 2.1.0.3 does not exist in the online gallery, an error occurs.

  5. Update a module regardless of the current version installed:
    PS C:\> Update-Module -Name "ContosoModule" -Force
    

    This example installs (or reinstalls) the newest version of ContosoModule from the online gallery, regardless of the current version of the module that is installed on the computer.

Additional Notes
 * This cmdlet runs on Windows PowerShell 3.0 or later releases of Windows PowerShell, on Windows 7 or Windows 
 2008 R2 and later releases of Windows.

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

 If Update-Module attempts to update binaries that are in use, Update-Module returns an error that identifies 
 the problem processes, and informs the user to retry Update-Module after stopping the processes.

This work is licensed under a Creative Commons Attribution 4.0 International. It is attributed to Microsoft Corporation and can be found here.

PowerShell Commands