Skip to content

Commit b64a109

Browse files
Merge pull request MicrosoftDocs#3357 from lanwench/PK-#3334
Quality: PowerShell Summit MicrosoftDocsGH-3334
2 parents e5701d5 + 539e032 commit b64a109

File tree

1 file changed

+76
-37
lines changed

1 file changed

+76
-37
lines changed

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

+76-37
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,42 @@ Gets one GPO or all the GPOs in a domain.
1616
## SYNTAX
1717

1818
### ByGUID (Default)
19+
1920
```
2021
Get-GPO [-Guid] <Guid> [[-Domain] <String>] [[-Server] <String>] [-All] [<CommonParameters>]
2122
```
2223

2324
### ByName
25+
2426
```
2527
Get-GPO [-Name] <String> [[-Domain] <String>] [[-Server] <String>] [-All] [<CommonParameters>]
2628
```
2729

2830
### GetAll
31+
2932
```
3033
Get-GPO [[-Domain] <String>] [[-Server] <String>] [-All] [<CommonParameters>]
3134
```
3235

3336
## DESCRIPTION
34-
The **Get-GPO** cmdlet gets one Group Policy Object (GPO) or all the GPOs in a domain.
35-
You can specify a GPO by its display name or by its globally unique identifier (GUID) to get a single GPO, or you can get all the GPOs in the domain through the *All* parameter.
37+
38+
The `Get-GPO` cmdlet gets one Group Policy Object (GPO) or all the GPOs in a domain.
39+
You can specify a GPO by its display name or by its globally unique identifier (GUID) to get a
40+
single GPO, or you can get all the GPOs in the domain through the **All** parameter.
3641

3742
This cmdlet returns one or more objects that represent the requested GPOs.
38-
By default, properties of the requested GPOs are printed to the display; however, you can also pipe the output of the **Get-GPO** cmdlet to other Group Policy cmdlets.
43+
By default, properties of the requested GPOs are printed to the display; however, you can also pipe
44+
the output of the `Get-GPO` cmdlet to other Group Policy cmdlets.
3945

4046
## EXAMPLES
4147

4248
### Example 1: Get a single GPO from a domain
49+
50+
```powershell
51+
Get-GPO -Name "Group Policy Test"
52+
```
53+
4354
```
44-
PS C:\> Get-GPO -Name "Group Policy Test"
4555
DisplayName : Group Policy Test
4656
4757
DomainName : contoso.com
@@ -66,12 +76,17 @@ WmiFilter :
6676
```
6777

6878
This command gets the GPO named Group Policy Test.
69-
The GPO must exist in the domain of the user that is running the session (or, for startup and shutdown scripts, the computer).
79+
The GPO must exist in the domain of the user that is running the session (or, for startup and
80+
shutdown scripts, the computer).
7081
The command gets the GPO information by contacting the primary domain controller (PDC).
7182

7283
### Example 2: Get a single GPO by GUID
84+
85+
```powershell
86+
Get-GPO -Guid 31a09564-cd4a-4520-98fa-446a2af23b4b -Domain "sales.contoso.com"
7387
```
74-
PS C:\> Get-GPO -Guid 31a09564-cd4a-4520-98fa-446a2af23b4b -Domain "sales.contoso.com"
88+
89+
```output
7590
DisplayName : Group Policy Test
7691
7792
DomainName : sales.contoso.com
@@ -95,20 +110,24 @@ ComputerVersion : AD Version: 0, SysVol Version: 0
95110
WmiFilter :
96111
```
97112

98-
This command gets the GPO that has the ID (GUID) 331a09564-cd4a-4520-98fa-446a2af23b4b in the sales.contoso.com domain.
99-
If the domain of the user that is running the session (or, for startup and shutdown scripts, the computer) is different that sales.contoso.com, a trust must exist between the two domains.
100-
The command retrieves the GPO information by contacting the PDC (in the sales.contoso.com domain).
113+
This command gets the GPO that has the ID (GUID) `331a09564-cd4a-4520-98fa-446a2af23b4b` in the
114+
`sales.contoso.com` domain.
115+
If the domain of the user that is running the session (or, for startup and shutdown scripts, the
116+
computer) is different than `sales.contoso.com`, a trust must exist between the two domains.
117+
The command retrieves the GPO information by contacting the PDC (in the `sales.contoso.com` domain).
101118

102119
### Example 3: Get all GPOs from a domain
103-
```
104-
PS C:\> Get-GPO -All -Domain "sales.contoso.com"
120+
121+
```powershell
122+
Get-GPO -All -Domain "sales.contoso.com"
105123
```
106124

107125
This command get all the GPOs in the sales.contoso.com domain.
108126

109127
## PARAMETERS
110128

111129
### -All
130+
112131
Indicates that the cmdlet gets all the GPOs in the domain.
113132

114133
```yaml
@@ -124,19 +143,24 @@ Accept wildcard characters: False
124143
```
125144
126145
### -Domain
146+
127147
Specifies the domain for this cmdlet.
128148
You must specify the fully qualified domain name (FQDN) of the domain.
129149
130-
For the **Get-GPO** cmdlet, the GPO (or GPOs) to that this cmdlet gets must exist in this domain.
150+
For the `Get-GPO` cmdlet, the GPO (or GPOs) to that this cmdlet gets must exist in this domain.
131151

132-
If you do not specify the *Domain* parameter, the domain of the user that is running the current session is used.
133-
If the cmdlet is being run from a computer startup or shutdown script, the domain of the computer is used.
152+
If you do not specify the **Domain** parameter, the domain of the user that is running the current
153+
session is used.
154+
If the cmdlet is being run from a computer startup or shutdown script, the domain of the computer
155+
is used.
134156
For more information, see the Notes section in the full Help.
135157

136-
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.
158+
If you specify a domain that is different from the domain of the user that is running the current
159+
session (or, for a startup or shutdown script, the computer), a trust must exist between that
160+
domain and the domain of the user or the computer.
137161

138-
You can also refer to the *Domain* parameter by its built-in alias, domainname.
139-
For more information, see about_Aliases.
162+
You can also refer to the **Domain** parameter by its built-in alias, **domainname.**
163+
For more information, see [about_Aliases](/powershell/module/microsoft.powershell.core/about/about_aliases).
140164

141165
```yaml
142166
Type: String
@@ -151,10 +175,11 @@ Accept wildcard characters: False
151175
```
152176

153177
### -Guid
178+
154179
Specifies the GPO to retrieve by its globally unique identifier (GUID).
155180
The GUID uniquely identifies the GPO.
156181

157-
You can also refer to the *Guid* parameter by its built-in alias, id.
182+
You can also refer to the **Guid** parameter by its built-in alias, **id.**
158183

159184
```yaml
160185
Type: Guid
@@ -169,13 +194,14 @@ Accept wildcard characters: False
169194
```
170195

171196
### -Name
197+
172198
Specifies the GPO to retrieve by its display name.
173199

174200
The display name is not guaranteed to be unique in the domain.
175201
If another GPO with the same display name exists in the domain an error occurs.
176202
You can use the Guid parameter to uniquely identify a GPO.
177203

178-
You can also refer to the *Name* parameter by its built-in alias, displayname.
204+
You can also refer to the **Name** parameter by its built-in alias, **displayname.**
179205

180206
```yaml
181207
Type: String
@@ -190,12 +216,14 @@ Accept wildcard characters: False
190216
```
191217

192218
### -Server
219+
193220
Specifies the name of the domain controller that this cmdlet contacts to complete the operation.
194221
You can specify either the fully qualified domain name (FQDN) or the host name.
195222

196-
If you do not specify the name by using the Server parameter, the primary domain controller (PDC) emulator is contacted.
223+
If you do not specify the name by using the Server parameter, the primary domain controller (PDC)
224+
emulator is contacted.
197225

198-
You can also refer to the Server parameter by its built-in alias, dc.
226+
You can also refer to the **Server** parameter by its built-in alias, **dc.**
199227

200228
```yaml
201229
Type: String
@@ -210,36 +238,47 @@ Accept wildcard characters: False
210238
```
211239

212240
### CommonParameters
213-
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).
241+
242+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
243+
-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
244+
-WarningAction, and -WarningVariable.
245+
For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
214246

215247
## INPUTS
216248

217249
### Microsoft.GroupPolicy.Gpo
250+
218251
You can pipe a GPO for which to get information to this cmdlet.
219252
You can pipe GPO objects into this cmdlet to display information about the GPOs.
220253
Collections that contain GPOs from different domains are not supported.
221254

222255
## OUTPUTS
223256

224257
### Microsoft.GroupPolicy.Gpo
258+
225259
This cmdlet returns an object that represents the requested GPO.
226260

227261
## NOTES
228-
* You can use the *Domain* parameter to explicitly specify the domain for this cmdlet.
229-
230-
If you do not explicitly specify the domain, the cmdlet uses a default domain.
231-
The default domain is the domain that is used to access network resources by the security context under which the current session is running.
232-
This domain is typically the domain of the user that is running the session.
233-
For example, 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.
234-
However, computer startup and shutdown scripts run under the context of the LocalSystem account.
235-
The LocalSystem account is a built-in local account, and it accesses network resources under the context of the computer account.
236-
Therefore, when this cmdlet is run from a startup or shutdown script, the default domain is the domain to which the computer is joined.
237-
238-
Only one domain can be used by an instance of this cmdlet.
239-
If you pipe a collection of GPO (Microsoft.GroupPolicy.Gpo) objects to this cmdlet, the DomainName property of the first GPO object in the collection specifies the domain for the cmdlet.
240-
This is because domainname is a built-in alias for the *Domain* parameter, and the *Domain* parameter can take its value by property name from the pipeline.
241-
A non-terminating error occurs for any GPOs in the collection that are not in this domain.
242-
If this domain is different from the domain of the user account (for startup or shutdown scripts, the computer account), a trust must exist between the two domains.
262+
263+
- You can use the **Domain** parameter to explicitly specify the domain for this cmdlet.
264+
265+
If you do not explicitly specify the domain, the cmdlet uses a default domain. The default domain
266+
is the domain that is used to access network resources by the security context under which the
267+
current session is running. This domain is typically the domain of the user that is running the
268+
session. For example, the domain of the user who started the session by opening Windows PowerShell
269+
from the Program Files menu, or the domain of a user that is specified in a runas command.
270+
However, computer startup and shutdown scripts run under the context of the LocalSystem account.
271+
The LocalSystem account is a built-in local account, and it accesses network resources under the
272+
context of the computer account. Therefore, when this cmdlet is run from a startup or shutdown
273+
script, the default domain is the domain to which the computer is joined.
274+
275+
Only one domain can be used by an instance of this cmdlet. If you pipe a collection of GPO
276+
(**Microsoft.GroupPolicy.Gpo**) objects to this cmdlet, the **DomainName** property of the first
277+
GPO object in the collection specifies the domain for the cmdlet. This is because **domainname**
278+
is a built-in alias for the **Domain** parameter, and the **Domain** parameter can take its value
279+
by property name from the pipeline. A non-terminating error occurs for any GPOs in the collection
280+
that are not in this domain. If this domain is different from the domain of the user account (for
281+
startup or shutdown scripts, the computer account), a trust must exist between the two domains.
243282

244283
## RELATED LINKS
245284

0 commit comments

Comments
 (0)