user1342164
user1342164

Reputation: 1454

Get computers list from certain OU in active directory?

I am using the powershell command below to get a list of computers that havent been logged into in the past 60 days. This is returning all OU computers. Is it possible to change the line below to return from a certain OU?

Get-ADComputer -Property Name,lastLogonDate -Filter {lastLogonDate -lt $then} | FT Name,lastLogonDate

Upvotes: 0

Views: 28023

Answers (1)

Mitul
Mitul

Reputation: 9854

From the online help page try using -SearchBase filter

C:\PS>Get-ADComputer -LDAPFilter "(name=*laptop*)" -SearchBase "CN=Computers,DC=Fabrikam,DC=com"

Upvotes: 3

Related Questions