Skip to content

Commit f3a5193

Browse files
authored
Merge pull request #4531 from davidsmatlak/ds-iss4529
Fixes #4529 - added Scope parameter to PS7 Update-Module
2 parents ee62fec + dcc7e9d commit f3a5193

File tree

1 file changed

+122
-52
lines changed

1 file changed

+122
-52
lines changed

reference/7/PowerShellGet/Update-Module.md

Lines changed: 122 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3,80 +3,104 @@ external help file: PSModule-help.xml
33
keywords: powershell,cmdlet
44
locale: en-us
55
Module Name: PowerShellGet
6-
ms.date: 06/09/2017
6+
ms.date: 07/05/2019
77
online version: https://go.microsoft.com/fwlink/?linkid=2096729
88
schema: 2.0.0
99
title: Update-Module
1010
---
11+
1112
# Update-Module
1213

1314
## SYNOPSIS
14-
Downloads and installs the newest version of specified modules from an online gallery to the local computer.
15+
Downloads and installs the newest version of specified modules from an online gallery to the local
16+
computer.
1517

1618
## SYNTAX
1719

20+
### All
21+
1822
```
1923
Update-Module [[-Name] <String[]>] [-RequiredVersion <String>] [-MaximumVersion <String>]
20-
[-Credential <PSCredential>] [-Proxy <Uri>] [-ProxyCredential <PSCredential>] [-Force] [-AllowPrerelease]
21-
[-AcceptLicense] [-WhatIf] [-Confirm] [<CommonParameters>]
24+
[-Credential <PSCredential>] [-Scope <String>] [-Proxy <Uri>] [-ProxyCredential <PSCredential>]
25+
[-Force] [-AllowPrerelease] [-AcceptLicense] [-WhatIf] [-Confirm] [<CommonParameters>]
2226
```
2327

2428
## DESCRIPTION
2529

26-
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.
2737

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.
3040

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`.
3242

3343
## EXAMPLES
3444

3545
### Example 1: Update all modules
3646

37-
```
38-
PS C:\> Update-Module
39-
```
47+
This example updates all installed modules to the newest version in an online gallery.
4048

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+
```
4252

4353
### Example 2: Update a module by name
4454

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
4759
```
4860

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**.
5262

53-
### Example 3: View what would occur if Update-Module runs
63+
### Example 3: View what-if Update-Module runs
5464

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
5570
```
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'".
5977
```
6078

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.
6380

6481
### Example 4: Update a module to a specified version
6582

66-
```
67-
PS C:\> Update-Module -Name "ContosoModule" -RequiredVersion 2.1.0.3
83+
In this example, a module is updated to a specific version. The version must exist in the online
84+
gallery or an error is displayed.
85+
86+
```powershell
87+
Update-Module -Name SpeculationControl -RequiredVersion 1.0.14
6888
```
6989

70-
This example updates ContosoModule to version 2.1.0.3.
71-
If version 2.1.0.3 does not exist in the online gallery, an error occurs.
90+
`Update-Module` uses the **Name** parameter to specify the module, **SpeculationControl**. The
91+
**RequiredVersion** parameter specifies the version, **1.0.14**.
7292

73-
### Example 5: Update a module regardless of the current version installed
93+
### Example 5: Update a module without confirmation
7494

75-
```
76-
PS C:\> Update-Module -Name "ContosoModule" -Force
95+
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
77100
```
78101

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.
80104

81105
## PARAMETERS
82106

@@ -114,6 +138,8 @@ Accept wildcard characters: False
114138
115139
### -Credential
116140
141+
Specifies a user account that has permission to update a module.
142+
117143
```yaml
118144
Type: PSCredential
119145
Parameter Sets: (All)
@@ -128,7 +154,8 @@ Accept wildcard characters: False
128154
129155
### -Force
130156
131-
Forces the update of each specified module, regardless of the current version of the module installed.
157+
Forces an update of each specified module without a prompt to request confirmation. If the module is
158+
already installed, **Force** reinstalls the module.
132159
133160
```yaml
134161
Type: SwitchParameter
@@ -144,9 +171,9 @@ Accept wildcard characters: False
144171
145172
### -MaximumVersion
146173
147-
Specifies the maximum version of a single module to update.
148-
You cannot add this parameter if you are attempting to update multiple modules.
149-
The *MaximumVersion* and the *RequiredVersion* parameters are mutually exclusive; you cannot use both parameters in the same command.
174+
Specifies the maximum version of a single module to update. You can't add this parameter if you're
175+
attempting to update multiple modules. The **MaximumVersion** and the **RequiredVersion** parameters
176+
can't be used in the same command.
150177
151178
```yaml
152179
Type: String
@@ -162,11 +189,12 @@ Accept wildcard characters: False
162189
163190
### -Name
164191
165-
Specifies the names of one or more modules to be updated.
166-
**Update-Module** searches $env:PSModulePath for the modules to update.
167-
Without wildcard characters, the only modules that are updated are those that exactly match specified names.
168-
If no matches are found for the specified modules in $env:PSModulePath, an error occurs.
169-
If you add wildcard characters to the name that you specify, but no matches are found, no error occurs.
192+
Specifies the names of one or more modules to update. `Update-Module` searches `$env:PSModulePath`
193+
for the modules to update. If no matches are found in `$env:PSModulePath` for the specified module
194+
name, an error occurs.
195+
196+
Wildcards are accepted in module names. If you add wildcard characters to the specified name and no
197+
matches are found, no error occurs.
170198

171199
```yaml
172200
Type: String[]
@@ -177,11 +205,13 @@ Required: False
177205
Position: 0
178206
Default value: None
179207
Accept pipeline input: True (ByPropertyName)
180-
Accept wildcard characters: False
208+
Accept wildcard characters: True
181209
```
182210

183211
### -Proxy
184212

213+
Specifies a proxy server for the request, rather than connecting directly to an internet resource.
214+
185215
```yaml
186216
Type: Uri
187217
Parameter Sets: (All)
@@ -196,6 +226,9 @@ Accept wildcard characters: False
196226

197227
### -ProxyCredential
198228

229+
Specifies a user account that has permission to use the proxy server specified by the **Proxy**
230+
parameter.
231+
199232
```yaml
200233
Type: PSCredential
201234
Parameter Sets: (All)
@@ -210,9 +243,9 @@ Accept wildcard characters: False
210243

211244
### -RequiredVersion
212245

213-
Specifies the exact version to which the existing installed module will be updated.
214-
You cannot add this parameter if you are updating more than one module in a single command.
215-
If the online gallery does not have this version of the specified module, an error occurs.
246+
Specifies the exact version to which the existing installed module will be updated. The version
247+
specified by **RequiredVersion** must exist in the online gallery or an error is displayed. If more
248+
than one module is updated in a single command, you can't use **RequiredVersion**.
216249

217250
```yaml
218251
Type: String
@@ -226,9 +259,37 @@ Accept pipeline input: True (ByPropertyName)
226259
Accept wildcard characters: False
227260
```
228261

262+
### -Scope
263+
264+
Specifies the installation scope of the module. The acceptable values for this parameter are
265+
**AllUsers** and **CurrentUser**.
266+
267+
The **AllUsers** scope installs modules in a location that is accessible to all users of the
268+
computer:
269+
270+
`$env:ProgramFiles\PowerShell\Modules`
271+
272+
The **CurrentUser** installs modules in a location that is accessible only to the current user of
273+
the computer:
274+
275+
`$home\Documents\PowerShell\Modules`
276+
277+
```yaml
278+
Type: String
279+
Parameter Sets: (All)
280+
Aliases:
281+
Accepted values: AllUsers, CurrentUser
282+
283+
Required: False
284+
Position: Named
285+
Default value: None
286+
Accept pipeline input: False
287+
Accept wildcard characters: False
288+
```
289+
229290
### -Confirm
230291

231-
Prompts you for confirmation before running the cmdlet.
292+
Prompts you for confirmation before running `Update-Module`.
232293

233294
```yaml
234295
Type: SwitchParameter
@@ -244,8 +305,7 @@ Accept wildcard characters: False
244305

245306
### -WhatIf
246307

247-
Shows what would happen if the cmdlet runs.
248-
The cmdlet is not run.
308+
Shows what would happen if `Update-Module` runs. The cmdlet isn't run.
249309

250310
```yaml
251311
Type: SwitchParameter
@@ -261,25 +321,35 @@ Accept wildcard characters: False
261321

262322
### CommonParameters
263323

264-
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,
325+
-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
326+
-WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
265327

266328
## INPUTS
267329

268330
## OUTPUTS
269331

270332
## NOTES
271333

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.
273336

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.
276339

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
345+
processes are stopped.
278346

279347
## RELATED LINKS
280348

281349
[Find-Module](Find-Module.md)
282350

351+
[Get-InstalledModule](Get-InstalledModule.md)
352+
283353
[Install-Module](Install-Module.md)
284354

285355
[Publish-Module](Publish-Module.md)

0 commit comments

Comments
 (0)