Update-Module
Syntax
Update-Module
[[-Name] <String[]>]
[-RequiredVersion <Version>]
[-MaximumVersion <Version>]
[-Credential <PSCredential>]
[-Proxy <Uri>]
[-ProxyCredential <PSCredential>]
[-Force]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
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.
Examples
Example 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.
Example 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.
Example 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.
Example 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.
Example 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.
Optional Parameters
Prompts you for confirmation before running the cmdlet.
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Type: | PSCredential |
Position: | Named |
Default value: | None |
Accept pipeline input: | True (ByPropertyName) |
Accept wildcard characters: | False |
Forces the update of each specified module, regardless of the current version of the module installed.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
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.
Type: | Version |
Position: | Named |
Default value: | None |
Accept pipeline input: | True (ByPropertyName) |
Accept wildcard characters: | False |
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.
Type: | String[] |
Position: | 1 |
Default value: | None |
Accept pipeline input: | True (ByPropertyName) |
Accept wildcard characters: | False |
Type: | Uri |
Position: | Named |
Default value: | None |
Accept pipeline input: | True (ByPropertyName) |
Accept wildcard characters: | False |
Type: | PSCredential |
Position: | Named |
Default value: | None |
Accept pipeline input: | True (ByPropertyName) |
Accept wildcard characters: | False |
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.
Type: | Version |
Position: | Named |
Default value: | None |
Accept pipeline input: | True (ByPropertyName) |
Accept wildcard characters: | False |
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: | SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
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.