You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The **Update-Module** cmdlet installs a newer version of a PowerShell module that was installed from the online gallery by running Install-Module on the local computer.
30
+
The `Update-Module` cmdlet installs a module's newest version from an online gallery. You're
31
+
prompted to confirm the update before it's installed. Updates are installed only for modules that
32
+
were installed on the local computer with `Install-Module`. `Update-Module` searches
33
+
`$env:PSModulePath` and updates a module's first occurrence.
34
+
35
+
`Update-Module` updates all installed modules. To specify a module to update, use the **Name**
36
+
parameter. You can update to a module's specific version by using the **RequiredVersion** parameter.
27
37
28
-
By default, the newest version of the specified module available in online gallery is installed, unless you specify a required version.
29
-
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.
38
+
If an installed module is the newest version, the module isn't updated. If the module isn't found in
39
+
`$env:PSModulePath`, an error is displayed.
30
40
31
-
Running **Update-Module** without the *Name* parameter updates all modules that can be updated on the local computer.
41
+
To display the installed modules, use `Get-InstalledModule`.
32
42
33
43
## EXAMPLES
34
44
35
45
### Example 1: Update all modules
36
46
37
-
```
38
-
PS C:\> Update-Module
39
-
```
47
+
This example updates all installed modules to the newest version in an online gallery.
40
48
41
-
This example updates to the newest version all modules in $env:PSModulePath that were installed by Install-Module from the online gallery.
49
+
```powershell
50
+
Update-Module
51
+
```
42
52
43
53
### Example 2: Update a module by name
44
54
45
-
```
46
-
PS C:\> Update-Module -Name "MyDscModule"
55
+
This example updates a specific module to the newest version in an online gallery.
56
+
57
+
```powershell
58
+
Update-Module -Name SpeculationControl
47
59
```
48
60
49
-
This example updates to the newest online gallery version the first module named MyDscModule found in $env:PSModulePath.
50
-
If the existing MyDscModule is already the newest version, nothing happens.
51
-
If **Update-Module** cannot find a module named MyDscModule in $env:PSModulePath, an error occurs.
61
+
`Update-Module` uses the **Name** parameter to update a specific module, **SpeculationControl**.
52
62
53
-
### Example 3: View what would occur if Update-Module runs
63
+
### Example 3: View what-if Update-Module runs
54
64
65
+
This example does a what-if scenario to show what happens if `Update-Module` is run. The command
66
+
isn't run.
67
+
68
+
```powershell
69
+
Update-Module -WhatIf
55
70
```
56
-
PS C:\> Update-Module -WhatIf
57
-
What if: Performing the operation "Update-Module" on target "Version '2.0' of module 'xDscDiagnostics', updating to version '2.0'".
58
-
What if: Performing the operation "Update-Module" on target "Version '1.1.1' of module 'xDSCResourceDesigner', updating to version '1.1.1.1'".
71
+
72
+
```Output
73
+
What if: Performing the operation "Update-Module" on target "Version '2.8.0' of module
74
+
'Carbon', updating to version '2.8.1'".
75
+
What if: Performing the operation "Update-Module" on target "Version '1.0.10' of module
76
+
'SpeculationControl', updating to version '1.0.14'".
59
77
```
60
78
61
-
This example shows what modules would be updated, and to which versions, if the **Update-Module** command were actually run.
62
-
The command is not run.
79
+
`Update-Module` uses the **WhatIf** parameter display what would happen if `Update-Module` were run.
63
80
64
81
### Example 4: Update a module to a specified version
This example doesn't request confirmation to update the module to the newest version from an online
96
+
gallery. If the module is already installed, the **Force** parameter reinstalls the module.
97
+
98
+
```powershell
99
+
Update-Module -Name SpeculationControl -Force
77
100
```
78
101
79
-
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.
102
+
`Update-Module` uses the **Name** parameter to specify the module, **SpeculationControl**. The
103
+
**Force** parameter updates the module without requesting user confirmation.
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
324
+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
265
327
266
328
## INPUTS
267
329
268
330
## OUTPUTS
269
331
270
332
## NOTES
271
333
272
-
* This cmdlet runs on Windows PowerShell 3.0 or later releases of PowerShell, on Windows 7 or Windows 2008 R2 and later releases of Windows.
334
+
`Update-Module`runs on PowerShell 3.0 or later releases of PowerShell, on Windows 7 or Windows 2008
335
+
R2 and later releases of Windows.
273
336
274
-
If the module that you specify with the **Name** parameter was not installed by using Install-Module, an error occurs.
275
-
You can only run **Update-Module** on modules that you installed from the online gallery by running Install-Module.
337
+
If the module that you specify with the **Name** parameter wasn't installed by using
338
+
`Install-Module`, an error occurs.
276
339
277
-
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.
340
+
You can only run `Update-Module` on modules that you installed from the online gallery by running
341
+
`Install-Module`.
342
+
343
+
If `Update-Module` attempts to update binaries that are in use, `Update-Module` returns an error
344
+
that identifies the problem processes. The user is informed to retry `Update-Module` after the
0 commit comments