Skip to content

Commit 64cb2d6

Browse files
fix code blocks
1 parent 916b682 commit 64cb2d6

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

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

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ For more information about the how to determine the properties for computer obje
6262
### Example 1: Get specific computer that shows all properties
6363

6464
```powershell
65-
PS C:\> Get-ADComputer -Identity "User01-SRV1" -Properties *
65+
Get-ADComputer -Identity "User01-SRV1" -Properties *
66+
```
67+
68+
```Output
6669
6770
6871
AccountExpirationDate :
@@ -148,7 +151,11 @@ This command gets a specific computer showing all the properties.
148151
### Example 2: Get all computers with a name starting with a particular string
149152

150153
```powershell
151-
PS C:\> Get-ADComputer -Filter 'Name -like "User01*"' -Properties IPv4Address | FT Name,DNSHostName,IPv4Address -A
154+
Get-ADComputer -Filter 'Name -like "User01*"' -Properties IPv4Address |
155+
Format-Table Name,DNSHostName,IPv4Address -AutoSize
156+
```
157+
158+
```Output
152159
name dnshostname ipv4address
153160
---- ----------- -----------
154161
User01-SRV1 User01-SRV1.User01.com 10.194.99.181
@@ -160,8 +167,12 @@ This command gets all the computers with a name starting with a particular strin
160167
### Example 3: Gets all computers that have changed their password in specific time frame
161168

162169
```powershell
163-
PS C:\> $Date = [DateTime]::Today.AddDays(-90)
164-
PS C:\> Get-ADComputer -Filter 'PasswordLastSet -ge $Date' -Properties PasswordLastSet | FT Name,PasswordLastSet
170+
$Date = [DateTime]::Today.AddDays(-90)
171+
Get-ADComputer -Filter 'PasswordLastSet -ge $Date' -Properties PasswordLastSet |
172+
Format-Table Name,PasswordLastSet
173+
```
174+
175+
```Output
165176
Name PasswordLastSet
166177
---- ---------------
167178
USER01-SRV4 3/12/2009 6:40:37 PM
@@ -173,7 +184,10 @@ This command gets all the computers that have changed their password in the last
173184
### Example 4: Get computer accounts in a specific location using an LDAPFilter
174185

175186
```powershell
176-
PS C:\> Get-ADComputer -LDAPFilter "(name=*laptop*)" -SearchBase "CN=Computers,DC= User01,DC=com"
187+
Get-ADComputer -LDAPFilter "(name=*laptop*)" -SearchBase "CN=Computers,DC= User01,DC=com"
188+
```
189+
190+
```Output
177191
name
178192
----
179193
pattiful-laptop
@@ -185,15 +199,19 @@ This command gets the computer accounts in the location CN=Computers,DC=User01,D
185199
### Example 5: Get all computer accounts using a filter
186200

187201
```powershell
188-
PS C:\> Get-ADComputer -Filter *
202+
Get-ADComputer -Filter *
189203
```
190204

191205
This command gets all computer accounts.
192206

193207
### Example 6: Get all computers with a name starting with Computer01 or Computer02
194208

195209
```powershell
196-
PS C:\> Get-ADComputer -Filter 'Name -like "Computer01*" -or Name -like "Computer02*"' -Properties IPv4Address | FT Name,DNSHostName,IPv4Address -A
210+
Get-ADComputer -Filter 'Name -like "Computer01*" -or Name -like "Computer02*"' -Properties IPv4Address |
211+
Format-Table Name,DNSHostName,IPv4Address -AutoSize
212+
```
213+
214+
```Output
197215
name dnshostname ipv4address
198216
---- ----------- -----------
199217
Computer01-SRV1 Computer01-SRV1.Computer01.com 10.194.99.181
@@ -203,8 +221,12 @@ Computer02-SRV2 Computer02-SRV2.Computer02.com 10.194.100.3
203221
### Example 7: Get all computers with a name starting with a string AND password last set before 30 days
204222

205223
```powershell
206-
PS C:\> $Date = [DateTime]::Today.AddDays(-30)
207-
PS C:\> Get-ADComputer -Filter 'Name -like "Computer01*" -and PasswordLastSet -ge $Date' -Properties IPv4Address | FT Name,DNSHostName,IPv4Address -A
224+
$Date = [DateTime]::Today.AddDays(-30)
225+
Get-ADComputer -Filter 'Name -like "Computer01*" -and PasswordLastSet -ge $Date' -Properties IPv4Address |
226+
Format-Table Name,DNSHostName,IPv4Address -AutoSize
227+
```
228+
229+
```Output
208230
name dnshostname ipv4address
209231
---- ----------- -----------
210232
Computer01-SRV1 Computer01-SRV1.Computer01.com 10.194.99.181

0 commit comments

Comments
 (0)