Cmdlets

Choose a cmdlet from the list on the left or search for a specific cmdlet. Choose a cmdlet from the list or search for a specific cmdlet.
About Help  Providers
 

Update-Module

Update-Module

psget.psm1, psget-2.psm1

Synopsis

Downloads and installs the newest version of specified modules from an online gallery to the local computer.

Syntax

Update-Module [-Name] [-Force] [-RequiredVersion] [-Confirm] [-WhatIf] [<CommonParameters>]

Detailed Description

Update-Module 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

-Force <SwitchParameter>

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

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

-Name <String[]>

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. This is standard wildcard character matching behavior in Windows PowerShell.

Aliases

None

Required?

false

Position

1

Default value

None

Accept pipeline input?

True (ByPropertyName)

Accept wildcard characters?

false

-RequiredVersion <Version>

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.

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

True (ByPropertyName)

Accept wildcard characters?

false

-Confirm <SwitchParameter>

Prompts you for confirmation before running the cmdlet.

Aliases

None

Required?

false

Position

named

Default value

false

Accept pipeline input?

false

Accept wildcard characters?

false

-WhatIf <SwitchParameter>

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

Aliases

None

Required?

false

Position

named

Default value

false

Accept pipeline input?

false

Accept wildcard characters?

false

Input Type


Return Type


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.

Examples

-------------------------- EXAMPLE 1 --------------------------

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

PS C:\>Update-Module

-------------------------- EXAMPLE 2 --------------------------

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.

PS C:\>Update-Module -Name MyDscModule

-------------------------- EXAMPLE 3 --------------------------

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.

PS C:\>Update-Module -WhatIfPerforming the operation "Update module from version 1.0 to version 2.0" on target "C:\ProgramFiles\WindowsPowerShell\Modules\Constoso"

-------------------------- EXAMPLE 4 --------------------------

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.

PS C:\>Update-Module -Name ContosoModule -RequiredVersion 2.1.0.3

-------------------------- EXAMPLE 5 --------------------------

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.

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

Online Version