Get inactive computers in domain using command line

Here is a quick command that can be run on the domain to see if there are are computer accounts in Active Directory that have been inactive for over a month:

dsquery computer "OU=OU NAME,DC=DOMAIN,DC=LOCAL" -inactive 4 -limit 0  

The inactive value increases by weeks so two months would be 8 and so on.

You can narrow down the OU by simply putting in the distinguished name of the OU in the “”

Cheers

Paul

About the author