Skip to content

Commit 939a223

Browse files
authored
Merge pull request MicrosoftDocs#3456 from pbossman/pbossman
Quality: PowerShell Summit - GroupPolicy module MicrosoftDocs#3322
2 parents 322f3a1 + 43192a8 commit 939a223

27 files changed

+3290
-2015
lines changed

docset/winserver2022-ps/grouppolicy/Backup-GPO.md

+96-60
Original file line numberDiff line numberDiff line change
@@ -11,79 +11,95 @@ title: Backup-GPO
1111
# Backup-GPO
1212

1313
## SYNOPSIS
14+
1415
Backs up one GPO or all the GPOs in a domain.
1516

1617
## SYNTAX
1718

1819
### BackupOne(GUID) (Default)
20+
1921
```
20-
Backup-GPO -Guid <Guid> -Path <String> [-Comment <String>] [-Domain <String>] [-Server <String>] [-WhatIf]
21-
[-Confirm] [<CommonParameters>]
22+
Backup-GPO -Guid <Guid> -Path <String> [-Comment <String>] [-Domain <String>] [-Server <String>]
23+
[-WhatIf] [-Confirm] [<CommonParameters>]
2224
```
2325

2426
### BackupOne(Name)
27+
2528
```
26-
Backup-GPO [-Name] <String> -Path <String> [-Comment <String>] [-Domain <String>] [-Server <String>] [-WhatIf]
27-
[-Confirm] [<CommonParameters>]
29+
Backup-GPO [-Name] <String> -Path <String> [-Comment <String>] [-Domain <String>]
30+
[-Server <String>] [-WhatIf] [-Confirm] [<CommonParameters>]
2831
```
2932

3033
### BackupAll
34+
3135
```
32-
Backup-GPO -Path <String> [-Comment <String>] [-Domain <String>] [-Server <String>] [-All] [-WhatIf] [-Confirm]
33-
[<CommonParameters>]
36+
Backup-GPO -Path <String> [-Comment <String>] [-Domain <String>] [-Server <String>] [-All]
37+
[-WhatIf] [-Confirm] [<CommonParameters>]
3438
```
3539

3640
## DESCRIPTION
37-
The **Backup-GPO** cmdlet backs up a specified Group Policy Object (GPO) or all the GPOs in a domain to a backup directory.
38-
The backup directory and GPO must already exist.
41+
42+
The `Backup-GPO` cmdlet backs up a specified Group Policy Object (GPO) or all the GPOs in a domain
43+
to a backup directory. The backup directory and GPO must already exist.
3944

4045
## EXAMPLES
4146

4247
### Example 1: Backup a GPO to a specific directory
48+
49+
```powershell
50+
Backup-Gpo -Name TestGPO -Path C:\GpoBackups -Comment "Weekly Backup"
4351
```
44-
PS C:\> Backup-Gpo -Name TestGPO -Path C:\GpoBackups -Comment "Weekly Backup"
45-
DisplayName : TestGPO
4652

53+
```output
54+
DisplayName : TestGPO
4755
GpoId : 35c12ab3-956c-45d5-973b-46b17d225f47
48-
4956
Id : 2b509d4e-40f5-4337-82f7-458584555d0c
50-
5157
BackupDirectory : C:\GpoBackups
52-
5358
CreationTime : 2/25/2009 8:48:19 PM
54-
5559
DomainName : contoso.com
56-
5760
Comment : Weekly Backup
5861
```
5962

60-
This command backs up the "TestGPO" GPO to the C:\GpoBackups directory.
63+
This command backs up the `TestGPO` GPO to the `C:\GpoBackups` directory.
6164
The specified comment is included in the GPO backup.
6265

6366
### Example 2: Backup a GPO with the specified GUID to a directory
64-
```
65-
PS C:\> Backup-Gpo -GUID fa4a9473-6e2a-4b87-ab78-175e68d97bde -Domain "contoso.com" -Server "DC1" -Path "\\Server1\GpoBackups"
67+
68+
```powershell
69+
$params = @{
70+
GUID = 'fa4a9473-6e2a-4b87-ab78-175e68d97bde'
71+
Domain = 'contoso.com'
72+
Server = 'DC1'
73+
Path = '\\Server1\GpoBackups'
74+
}
75+
Backup-Gpo @params
6676
```
6777

68-
This command backs up the GPO with the specified GUID in the contoso.com domain to the \\\\Server1\GpoBackups directory.
69-
The domain controller at DC1.contoso.com is contacted to complete the operation.
78+
This command backs up the GPO with the specified **GUID** in the `contoso.com` domain to the
79+
`\\Server1\GpoBackups` directory. The domain controller at `DC1` is contacted to complete
80+
the operation.
7081

71-
If the domain of the user running the session (or, for startup and shutdown scripts, the computer) is different from the contoso.com domain, a trust must exist between the two domains or the command fails.
82+
If the domain of the user running the session (or, for startup and shutdown scripts, the computer)
83+
is different from the `contoso.com` domain, a trust must exist between the two domains or the
84+
command fails.
7285

7386
### Example 3: Backup all GPOs in the domain of the user that is running the session
74-
```
75-
PS C:\> Backup-Gpo -All -Path "\\Server1\GpoBackups"
87+
88+
```powershell
89+
Backup-Gpo -All -Path "\\Server1\GpoBackups"
7690
```
7791

78-
This command backs up all the GPOs in the domain of the user that is running the session (or, for startup and shutdown scripts, the computer) to the \\\\Server1\GpoBackups directory.
92+
This command backs up all the GPOs in the domain of the user that is running the session (or, for
93+
startup and shutdown scripts, the computer) to the `\\Server1\GpoBackups` directory.
7994

8095
## PARAMETERS
8196

8297
### -All
98+
8399
Specifies that all the GPOs in the domain are backed up.
84100

85101
```yaml
86-
Type: SwitchParameter
102+
Type: System.Management.Automation.SwitchParameter
87103
Parameter Sets: BackupAll
88104
Aliases:
89105

@@ -95,11 +111,12 @@ Accept wildcard characters: False
95111
```
96112
97113
### -Comment
98-
Specifies a comment for the backed-up GPO.
99-
The comment string must be enclosed in double-quotation or single-quotation marks and can contain 2,047 characters.
114+
115+
Specifies a comment for the backed-up GPO. The comment string must be enclosed in double-quotation
116+
or single-quotation marks and can contain 2,047 characters.
100117
101118
```yaml
102-
Type: String
119+
Type: System.String
103120
Parameter Sets: (All)
104121
Aliases:
105122

@@ -111,10 +128,11 @@ Accept wildcard characters: False
111128
```
112129
113130
### -Confirm
131+
114132
Prompts you for confirmation before running the cmdlet.
115133
116134
```yaml
117-
Type: SwitchParameter
135+
Type: System.Management.Automation.SwitchParameter
118136
Parameter Sets: (All)
119137
Aliases: cf
120138

@@ -126,21 +144,25 @@ Accept wildcard characters: False
126144
```
127145
128146
### -Domain
129-
Specifies the domain for this cmdlet.
130-
You must specify the fully qualified domain name (FQDN) of the domain (for example: sales.contoso.com).
147+
148+
Specifies the domain for this cmdlet. You must specify the fully qualified domain name (FQDN) of the
149+
domain (for example: sales.contoso.com).
131150
132151
For the **Backup-GPO** cmdlet, the GPO to back up must exist in this domain.
133152
134-
If you do not specify the *Domain* parameter, the domain of the user that is running the current session is used.
135-
(If the cmdlet is being run from a computer startup or shutdown script, the domain of the computer is used.) For more information, see the Notes section in the full Help.
153+
If you do not specify the **Domain** parameter, the domain of the user that is running the current
154+
session is used. (If the cmdlet is being run from a computer startup or shutdown script, the domain
155+
of the computer is used.) For more information, see the Notes section in the full Help.
136156
137-
If you specify a domain that is different from the domain of the user that is running the current session (or, for a startup or shutdown script, the computer), a trust must exist between that domain and the domain of the user (or the computer).
157+
If you specify a domain that is different from the domain of the user that is running the current
158+
session (or, for a startup or shutdown script, the computer), a trust must exist between that domain
159+
and the domain of the user (or the computer).
138160
139-
You can also refer to Domain by its built-in alias, domainname.
140-
For more information, see about_Aliases.
161+
You can also refer to Domain by its built-in alias, domain name. For more information, see
162+
[about_Aliases](/powershell/module/microsoft.powershell.core/about/about_aliases)
141163
142164
```yaml
143-
Type: String
165+
Type: System.String
144166
Parameter Sets: (All)
145167
Aliases: DomainName
146168

@@ -152,14 +174,15 @@ Accept wildcard characters: False
152174
```
153175
154176
### -Guid
177+
155178
Specifies the GPO to backup by its globally unique identifier (GUID).
156179
The GUID uniquely identifies the GPO.
157180
158-
You can also refer to the *Guid* parameter by its built-in alias, id.
159-
For more information, see **about_Aliases**.
181+
You can also refer to the **Guid** parameter by its built-in alias, **Id**. For more information,
182+
see [about_Aliases](/powershell/module/microsoft.powershell.core/about/about_aliases).
160183
161184
```yaml
162-
Type: Guid
185+
Type: Guid
163186
Parameter Sets: BackupOne(GUID)
164187
Aliases: Id
165188

@@ -171,17 +194,18 @@ Accept wildcard characters: False
171194
```
172195
173196
### -Name
197+
174198
Specifies the GPO to backup by its display name.
175199
176200
The display name is not guaranteed to be unique in the domain.
177201
If another GPO with the same display name exists in the domain an error occurs.
178-
You can use the *Guid* parameter to uniquely identify a GPO.
202+
You can use the **Guid** parameter to uniquely identify a GPO.
179203
180-
You can also refer to the Name parameter by its built-in alias, displayname.
181-
For more information, see **about_Aliases**.
204+
You can also refer to the Name parameter by its built-in alias, **DisplayName**. For more
205+
information, see [about_Aliases](/powershell/module/microsoft.powershell.core/about/about_aliases).
182206
183207
```yaml
184-
Type: String
208+
Type: System.String
185209
Parameter Sets: BackupOne(Name)
186210
Aliases: DisplayName
187211

@@ -193,12 +217,13 @@ Accept wildcard characters: False
193217
```
194218
195219
### -Path
196-
Specifies the path to the backup directory; for instance, "C:\Backups" or "\\\\MyServer\Backups".
220+
221+
Specifies the path to the backup directory; for instance, `C:\Backups` or `\\MyServer\Backups`.
197222

198223
```yaml
199-
Type: String
224+
Type: System.String
200225
Parameter Sets: (All)
201-
Aliases: backupLocation
226+
Aliases: BackupLocation
202227
203228
Required: True
204229
Position: Named
@@ -208,13 +233,14 @@ Accept wildcard characters: False
208233
```
209234

210235
### -Server
236+
211237
Specifies the name of the domain controller that this cmdlet contacts to complete the operation.
212238
You can specify either the fully qualified domain name (FQDN) or the host name.
213239

214-
If you do not specify the name by using the *Server* parameter, the PDC emulator is contacted.
240+
If you do not specify the name by using the **Server** parameter, the PDC emulator is contacted.
215241

216242
```yaml
217-
Type: String
243+
Type: System.String
218244
Parameter Sets: (All)
219245
Aliases: DC
220246
@@ -226,11 +252,12 @@ Accept wildcard characters: False
226252
```
227253

228254
### -WhatIf
255+
229256
Shows what would happen if the cmdlet runs.
230257
The cmdlet is not run.
231258

232259
```yaml
233-
Type: SwitchParameter
260+
Type: System.Management.Automation.SwitchParameter
234261
Parameter Sets: (All)
235262
Aliases: wi
236263
@@ -242,29 +269,38 @@ Accept wildcard characters: False
242269
```
243270

244271
### CommonParameters
245-
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
272+
273+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
274+
-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
275+
-WarningAction, and -WarningVariable. For more information, see
276+
[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
246277

247278
## INPUTS
248279

249280
### Microsoft.GroupPolicy.Gpo
281+
250282
A GPO to be backed up.
251283
Collections that contain GPOs from different domains are not supported.
252284

253285
## OUTPUTS
254286

255287
### Microsoft.GroupPolicy.GpoBackup
288+
256289
This cmdlet returns an object that represents the file that holds the settings of the backed-up GPO.
257290

258291
## NOTES
259-
* You can use the *Domain* parameter to explicitly specify the domain for this cmdlet.
260-
261-
If you do not explicitly specify the domain, the cmdlet uses a default domain.
262-
The default domain is the domain that is used to access network resources by the security context under which the current session is running.
263-
This domain is typically the domain of the user that is running the session.
264-
For instance, the domain of the user who started the session by opening Windows PowerShell from the Program Files menu, or the domain of a user that is specified in a runas command.
265-
However, computer startup and shutdown scripts run under the context of the LocalSystem account.
266-
The LocalSystem account is a built-in local account, and it accesses network resources under the context of the computer account.
267-
Therefore, when this cmdlet is run from a startup or shutdown script, the default domain is the domain to which the computer is joined.
292+
293+
* You can use the **Domain** parameter to explicitly specify the domain for this cmdlet.
294+
295+
If you do not explicitly specify the domain, the cmdlet uses a default domain. The default domain
296+
is the domain that is used to access network resources by the security context under which the
297+
current session is running. This domain is typically the domain of the user that is running the
298+
session. For instance, the domain of the user who started the session by opening Windows
299+
PowerShell from the Program Files menu, or the domain of a user that is specified in a runas
300+
command. However, computer startup and shutdown scripts run under the context of the LocalSystem
301+
account. The LocalSystem account is a built-in local account, and it accesses network resources
302+
under the context of the computer account. Therefore, when this cmdlet is run from a startup or
303+
shutdown script, the default domain is the domain to which the computer is joined.
268304

269305
## RELATED LINKS
270306

0 commit comments

Comments
 (0)