Skip to content

Commit 916b682

Browse files
auto format
1 parent bd7d419 commit 916b682

File tree

1 file changed

+67
-41
lines changed

1 file changed

+67
-41
lines changed

docset/winserver2022-ps/activedirectory/Get-ADComputer.md

Lines changed: 67 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -11,50 +11,56 @@ title: Get-ADComputer
1111
# Get-ADComputer
1212

1313
## SYNOPSIS
14+
1415
Gets one or more Active Directory computers.
1516

1617
## SYNTAX
1718

1819
### Filter (Default)
20+
1921
```powershell
2022
Get-ADComputer [-AuthType <ADAuthType>] [-Credential <PSCredential>] -Filter <String> [-Properties <String[]>]
2123
[-ResultPageSize <Int32>] [-ResultSetSize <Int32>] [-SearchBase <String>] [-SearchScope <ADSearchScope>]
2224
[-Server <String>] [<CommonParameters>]
2325
```
2426

2527
### Identity
28+
2629
```powershell
2730
Get-ADComputer [-AuthType <ADAuthType>] [-Credential <PSCredential>] [-Identity] <ADComputer>
2831
[-Partition <String>] [-Properties <String[]>] [-Server <String>] [<CommonParameters>]
2932
```
3033

3134
### LdapFilter
35+
3236
```powershell
3337
Get-ADComputer [-AuthType <ADAuthType>] [-Credential <PSCredential>] -LDAPFilter <String>
3438
[-Properties <String[]>] [-ResultPageSize <Int32>] [-ResultSetSize <Int32>] [-SearchBase <String>]
3539
[-SearchScope <ADSearchScope>] [-Server <String>] [<CommonParameters>]
3640
```
3741

3842
## DESCRIPTION
43+
3944
The **Get-ADComputer** cmdlet gets a computer or performs a search to retrieve multiple computers.
4045

41-
The *Identity* parameter specifies the Active Directory computer to retrieve.
46+
The _Identity_ parameter specifies the Active Directory computer to retrieve.
4247
You can identify a computer by its distinguished name, GUID, security identifier (SID) or Security Accounts Manager (SAM) account name.
43-
You can also set the parameter to a computer object variable, such as `$<localComputerobject>` or pass a computer object through the pipeline to the *Identity* parameter.
48+
You can also set the parameter to a computer object variable, such as `$<localComputerobject>` or pass a computer object through the pipeline to the _Identity_ parameter.
4449

45-
To search for and retrieve more than one computer, use the *Filter* or *LDAPFilter* parameters.
46-
The *Filter* parameter uses the PowerShell Expression Language to write query strings for Active Directory.
47-
PowerShell Expression Language syntax provides rich type conversion support for value types received by the *Filter* parameter.
48-
For more information about the *Filter* parameter syntax, type `Get-Help` [about_ActiveDirectory_Filter](/previous-versions/windows/server/hh531527(v=ws.10)).
49-
If you have existing Lightweight Directory Access Protocol (LDAP) query strings, you can use the *LDAPFilter* parameter.
50+
To search for and retrieve more than one computer, use the _Filter_ or _LDAPFilter_ parameters.
51+
The _Filter_ parameter uses the PowerShell Expression Language to write query strings for Active Directory.
52+
PowerShell Expression Language syntax provides rich type conversion support for value types received by the _Filter_ parameter.
53+
For more information about the _Filter_ parameter syntax, type `Get-Help` [about_ActiveDirectory_Filter](/previous-versions/windows/server/hh531527(v=ws.10)).
54+
If you have existing Lightweight Directory Access Protocol (LDAP) query strings, you can use the _LDAPFilter_ parameter.
5055

5156
This cmdlet retrieves a default set of computer object properties.
52-
To retrieve additional properties use the *Properties* parameter.
53-
For more information about the how to determine the properties for computer objects, see the *Properties* parameter description.
57+
To retrieve additional properties use the _Properties_ parameter.
58+
For more information about the how to determine the properties for computer objects, see the _Properties_ parameter description.
5459

5560
## EXAMPLES
5661

5762
### Example 1: Get specific computer that shows all properties
63+
5864
```powershell
5965
PS C:\> Get-ADComputer -Identity "User01-SRV1" -Properties *
6066
@@ -140,6 +146,7 @@ whenCreated : 3/16/2009 4:15:00 PM
140146
This command gets a specific computer showing all the properties.
141147

142148
### Example 2: Get all computers with a name starting with a particular string
149+
143150
```powershell
144151
PS C:\> Get-ADComputer -Filter 'Name -like "User01*"' -Properties IPv4Address | FT Name,DNSHostName,IPv4Address -A
145152
name dnshostname ipv4address
@@ -151,6 +158,7 @@ User01-SRV2 User01-SRV2.User01.com 10.194.100.3
151158
This command gets all the computers with a name starting with a particular string and shows the name, dns hostname, and IPv4 address.
152159

153160
### Example 3: Gets all computers that have changed their password in specific time frame
161+
154162
```powershell
155163
PS C:\> $Date = [DateTime]::Today.AddDays(-90)
156164
PS C:\> Get-ADComputer -Filter 'PasswordLastSet -ge $Date' -Properties PasswordLastSet | FT Name,PasswordLastSet
@@ -163,6 +171,7 @@ USER01-SRV5 3/12/2009 7:05:45 PM
163171
This command gets all the computers that have changed their password in the last 90 days.
164172

165173
### Example 4: Get computer accounts in a specific location using an LDAPFilter
174+
166175
```powershell
167176
PS C:\> Get-ADComputer -LDAPFilter "(name=*laptop*)" -SearchBase "CN=Computers,DC= User01,DC=com"
168177
name
@@ -171,16 +180,18 @@ pattiful-laptop
171180
davidche-laptop
172181
```
173182

174-
This command gets the computer accounts in the location CN=Computers,DC=User01,DC=com that are listed as laptops by using an *LDAPFilter*.
183+
This command gets the computer accounts in the location CN=Computers,DC=User01,DC=com that are listed as laptops by using an _LDAPFilter_.
175184

176185
### Example 5: Get all computer accounts using a filter
186+
177187
```powershell
178188
PS C:\> Get-ADComputer -Filter *
179189
```
180190

181191
This command gets all computer accounts.
182192

183193
### Example 6: Get all computers with a name starting with Computer01 or Computer02
194+
184195
```powershell
185196
PS C:\> Get-ADComputer -Filter 'Name -like "Computer01*" -or Name -like "Computer02*"' -Properties IPv4Address | FT Name,DNSHostName,IPv4Address -A
186197
name dnshostname ipv4address
@@ -190,6 +201,7 @@ Computer02-SRV2 Computer02-SRV2.Computer02.com 10.194.100.3
190201
```
191202

192203
### Example 7: Get all computers with a name starting with a string AND password last set before 30 days
204+
193205
```powershell
194206
PS C:\> $Date = [DateTime]::Today.AddDays(-30)
195207
PS C:\> Get-ADComputer -Filter 'Name -like "Computer01*" -and PasswordLastSet -ge $Date' -Properties IPv4Address | FT Name,DNSHostName,IPv4Address -A
@@ -200,10 +212,10 @@ Computer01-SRV1 Computer01-SRV1.Computer01.com 10.194.99.181
200212

201213
This command shows the name, DNS hostname, and IPv4 address.
202214

203-
204215
## PARAMETERS
205216

206217
### -AuthType
218+
207219
Specifies the authentication method to use.
208220
The acceptable values for this parameter are:
209221

@@ -228,6 +240,7 @@ Accept wildcard characters: False
228240
```
229241
230242
### -Credential
243+
231244
Specifies the user account credentials to use to perform this task.
232245
The default credentials are the credentials of the currently logged on user unless the cmdlet is run from an Active Directory module for Windows PowerShell provider drive.
233246
If the cmdlet is run from such a provider drive, the account associated with the drive is the default.
@@ -236,7 +249,7 @@ To specify this parameter, you can type a user name, such as User1 or Domain01\U
236249
If you specify a user name for this parameter, the cmdlet prompts for a password.
237250
238251
You can also create a **PSCredential** object by using a script or by using the **Get-Credential** cmdlet.
239-
You can then set the *Credential* parameter to the **PSCredential** object.
252+
You can then set the _Credential_ parameter to the **PSCredential** object.
240253
241254
If the acting credentials do not have directory-level permission to perform the task, Active Directory module for Windows PowerShell returns a terminating error.
242255
@@ -253,11 +266,12 @@ Accept wildcard characters: False
253266
```
254267
255268
### -Filter
269+
256270
Specifies a query string that retrieves Active Directory objects.
257271
This string uses the Windows PowerShell Expression Language syntax.
258-
The Windows PowerShell Expression Language syntax provides rich type-conversion support for value types received by the *Filter* parameter.
272+
The Windows PowerShell Expression Language syntax provides rich type-conversion support for value types received by the _Filter_ parameter.
259273
The syntax uses an in-order representation, which means that the operator is placed between the operand and the value.
260-
For more information about the *Filter* parameter, type `Get-Help` [about_ActiveDirectory_Filter](/previous-versions/windows/server/hh531527(v=ws.10)).
274+
For more information about the _Filter_ parameter, type `Get-Help` [about_ActiveDirectory_Filter](/previous-versions/windows/server/hh531527(v=ws.10)).
261275

262276
Syntax:
263277

@@ -281,10 +295,9 @@ The following syntax uses Backus-Naur form to show how to use the Windows PowerS
281295

282296
For a list of supported types for \<value\>, type `Get-Help about_ActiveDirectory_ObjectModel`.
283297

284-
Note: Windows PowerShell wildcards other than \*, such as ?, are not supported by the *Filter* syntax.
285-
286-
Note: To query using LDAP query strings, use the *LDAPFilter* parameter.
298+
Note: Windows PowerShell wildcards other than \*, such as ?, are not supported by the _Filter_ syntax.
287299

300+
Note: To query using LDAP query strings, use the _LDAPFilter_ parameter.
288301

289302
```yaml
290303
Type: String
@@ -299,13 +312,14 @@ Accept wildcard characters: False
299312
```
300313

301314
### -Identity
315+
302316
Specifies an Active Directory computer object by providing one of the following property values.
303317
The identifier in parentheses is the LDAP display name for the attribute.
304318
The acceptable values for this parameter are:
305319

306320
- A distinguished name
307-
- A GUID (objectGUID)
308-
- A security identifier (objectSid)
321+
- A GUID (objectGUID)
322+
- A security identifier (objectSid)
309323
- A Security Accounts Manager account name (sAMAccountName)
310324

311325
The cmdlet searches the default naming context or partition to find the object.
@@ -327,10 +341,11 @@ Accept wildcard characters: False
327341
```
328342

329343
### -LDAPFilter
344+
330345
Specifies an LDAP query string that is used to filter Active Directory objects.
331346
You can use this parameter to run your existing LDAP queries.
332-
The *Filter* parameter syntax supports the same functionality as the LDAP syntax.
333-
For more information, see the *Filter* parameter description or type `Get-Help` [about_ActiveDirectory_Filter](/previous-versions/windows/server/hh531527(v=ws.10)).
347+
The _Filter_ parameter syntax supports the same functionality as the LDAP syntax.
348+
For more information, see the _Filter_ parameter description or type `Get-Help` [about_ActiveDirectory_Filter](/previous-versions/windows/server/hh531527(v=ws.10)).
334349

335350
```yaml
336351
Type: String
@@ -345,27 +360,28 @@ Accept wildcard characters: False
345360
```
346361

347362
### -Partition
363+
348364
Specifies the distinguished name of an Active Directory partition.
349365
The distinguished name must be one of the naming contexts on the current directory server.
350-
The cmdlet searches this partition to find the object defined by the *Identity* parameter.
366+
The cmdlet searches this partition to find the object defined by the _Identity_ parameter.
351367

352-
In many cases, a default value is used for the *Partition* parameter if no value is specified.
368+
In many cases, a default value is used for the _Partition_ parameter if no value is specified.
353369
The rules for determining the default value are given below.
354370
Note that rules listed first are evaluated first and once a default value can be determined, no further rules are evaluated.
355371

356-
In Active Directory Domain Services environments, a default value for *Partition* is set in the following cases:
372+
In Active Directory Domain Services environments, a default value for _Partition_ is set in the following cases:
357373

358-
- If the *Identity* parameter is set to a distinguished name, the default value of *Partition* is automatically generated from this distinguished name.
359-
- If running cmdlets from an Active Directory provider drive, the default value of *Partition* is automatically generated from the current path in the drive.
360-
- If none of the previous cases apply, the default value of *Partition* is set to the default partition or naming context of the target domain.
374+
- If the _Identity_ parameter is set to a distinguished name, the default value of _Partition_ is automatically generated from this distinguished name.
375+
- If running cmdlets from an Active Directory provider drive, the default value of _Partition_ is automatically generated from the current path in the drive.
376+
- If none of the previous cases apply, the default value of _Partition_ is set to the default partition or naming context of the target domain.
361377

362-
In Active Directory Lightweight Directory Services (AD LDS) environments, a default value for *Partition* is set in the following cases:
378+
In Active Directory Lightweight Directory Services (AD LDS) environments, a default value for _Partition_ is set in the following cases:
363379

364-
- If the *Identity* parameter is set to a distinguished name, the default value of *Partition* is automatically generated from this distinguished name.
365-
- If running cmdlets from an Active Directory provider drive, the default value of *Partition* is automatically generated from the current path in the drive.
366-
- If the target AD LDS instance has a default naming context, the default value of *Partition* is set to the default naming context.
367-
To specify a default naming context for an AD LDS environment, set the **msDS-defaultNamingContext** property of the Active Directory directory service agent (DSA) object (**nTDSDSA**) for the AD LDS instance.
368-
- If none of the previous cases apply, the *Partition* parameter will not take any default value.
380+
- If the _Identity_ parameter is set to a distinguished name, the default value of _Partition_ is automatically generated from this distinguished name.
381+
- If running cmdlets from an Active Directory provider drive, the default value of _Partition_ is automatically generated from the current path in the drive.
382+
- If the target AD LDS instance has a default naming context, the default value of _Partition_ is set to the default naming context.
383+
To specify a default naming context for an AD LDS environment, set the **msDS-defaultNamingContext** property of the Active Directory directory service agent (DSA) object (**nTDSDSA**) for the AD LDS instance.
384+
- If none of the previous cases apply, the _Partition_ parameter will not take any default value.
369385

370386
```yaml
371387
Type: String
@@ -380,6 +396,7 @@ Accept wildcard characters: False
380396
```
381397

382398
### -Properties
399+
383400
Specifies the properties of the output object to retrieve from the server.
384401
Use this parameter to retrieve properties that are not included in the default set.
385402

@@ -404,6 +421,7 @@ Accept wildcard characters: False
404421
```
405422

406423
### -ResultPageSize
424+
407425
Specifies the number of objects to include in one page for an Active Directory Domain Services query.
408426

409427
The default is 256 objects per page.
@@ -421,6 +439,7 @@ Accept wildcard characters: False
421439
```
422440

423441
### -ResultSetSize
442+
424443
Specifies the maximum number of objects to return for an Active Directory Domain Services query.
425444
If you want to receive all of the objects, set this parameter to $Null (null value).
426445
You can use Ctrl+C to stop the query and return of objects.
@@ -440,6 +459,7 @@ Accept wildcard characters: False
440459
```
441460

442461
### -SearchBase
462+
443463
Specifies an Active Directory path to search under.
444464

445465
When you run a cmdlet from an Active Directory provider drive, the default value of this parameter is the current path of the drive.
@@ -449,8 +469,8 @@ When you run a cmdlet outside of an Active Directory provider drive against an A
449469
When you run a cmdlet outside of an Active Directory provider drive against an AD LDS target, the default value is the default naming context of the target AD LDS instance if one has been specified by setting the **msDS-defaultNamingContext** property of the Active Directory directory service agent object (**nTDSDSA**) for the AD LDS instance.
450470
If no default naming context has been specified for the target AD LDS instance, then this parameter has no default value.
451471

452-
When the value of the *SearchBase* parameter is set to an empty string and you are connected to a global catalog port, all partitions are searched.
453-
If the value of the *SearchBase* parameter is set to an empty string and you are not connected to a global catalog port, an error is thrown.
472+
When the value of the _SearchBase_ parameter is set to an empty string and you are connected to a global catalog port, all partitions are searched.
473+
If the value of the _SearchBase_ parameter is set to an empty string and you are not connected to a global catalog port, an error is thrown.
454474

455475
```yaml
456476
Type: String
@@ -465,6 +485,7 @@ Accept wildcard characters: False
465485
```
466486

467487
### -SearchScope
488+
468489
Specifies the scope of an Active Directory search.
469490
The acceptable values for this parameter are:
470491

@@ -490,25 +511,26 @@ Accept wildcard characters: False
490511
```
491512

492513
### -Server
514+
493515
Specifies the Active Directory Domain Services instance to connect to, by providing one of the following values for a corresponding domain name or directory server.
494516
The service may be any of the following: Active Directory Lightweight Domain Services, Active Directory Domain Services or Active Directory snapshot instance.
495517

496-
Specify the Active Directory Domain Services instance in one of the following ways:
518+
Specify the Active Directory Domain Services instance in one of the following ways:
497519

498520
Domain name values:
499521

500522
- Fully qualified domain name
501523
- NetBIOS name
502524

503-
Directory server values:
525+
Directory server values:
504526

505527
- Fully qualified directory server name
506528
- NetBIOS name
507529
- Fully qualified directory server name and port
508530

509531
The default value for this parameter is determined by one of the following methods in the order that they are listed:
510532

511-
- By using the *Server* value from objects passed through the pipeline
533+
- By using the _Server_ value from objects passed through the pipeline
512534
- By using the server information associated with the Active Directory Domain Services Windows PowerShell provider drive, when the cmdlet runs in that drive
513535
- By using the domain of the computer running Windows PowerShell
514536

@@ -525,20 +547,23 @@ Accept wildcard characters: False
525547
```
526548

527549
### CommonParameters
550+
528551
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).
529552

530553
## INPUTS
531554

532555
### None or Microsoft.ActiveDirectory.Management.ADComputer
533-
A computer object is received by the *Identity* parameter.
556+
557+
A computer object is received by the _Identity_ parameter.
534558

535559
## OUTPUTS
536560

537561
### Microsoft.ActiveDirectory.Management.ADComputer
562+
538563
Returns one or more computer objects.
539564

540565
This Get-ADComputer cmdlet returns a default set of **ADComputer** property values.
541-
To retrieve additional **ADComputer** properties, use the *Properties* parameter of this cmdlet.
566+
To retrieve additional **ADComputer** properties, use the _Properties_ parameter of this cmdlet.
542567

543568
To view the properties for an **ADComputer** object, see the following examples.
544569
To run these examples, replace \<computer\> with a computer identifier such as the SAM account name of your local computer.
@@ -552,7 +577,8 @@ To get a list of all the properties of an ADComputer object, use the following c
552577
`Get-ADComputer`\<computer\>`-Properties ALL | Get-Member`
553578

554579
## NOTES
555-
* This cmdlet does not work with AD LDS with its default schema. By default AD LDS schema does not have a computer class, but if the schema is extended to include it, this cmdlet will work with LDS.
580+
581+
- This cmdlet does not work with AD LDS with its default schema. By default AD LDS schema does not have a computer class, but if the schema is extended to include it, this cmdlet will work with LDS.
556582

557583
## RELATED LINKS
558584

0 commit comments

Comments
 (0)