Hello All,
I am a beginner in powershell. i managed to construct a query to find out the inactive computers with last logon name. but the problem is that query time out everytime. if i limit the scope to an OU with less no of systems, then we get to see the results. (eg; from 10k machines to 3k machines)....
is there any way to fine tune this query so that i can run it against all machines in AD .. say around 80k....
import-module Activedirectory $DaysInactive = 60 $time = (Get-Date).Adddays(-($DaysInactive)) Get-ADComputer -SearchBase "ou=a,DC=x,DC=y,DC=z" -Filter {(lastLogonTimestamp -lt $time) -and (operatingsystem -notlike '*server*') -and (operatingsystem -notlike "*embedded*") } -Properties LastLogonDate,operatingsystem | select Name,LastLogonDate,operatingsystem,distinguishedname
JG