Inactive computer account clean up

                         As workstations get added and removed to AD, computer accounts become needs to be cleaned up so they can be used for new computers. The following Powershell code retrieves all computers that either has not logged into AD for more than 90 days or never logged in and exports into a file.

Get-QADComputer -SizeLimit 0 -IncludedProperties LastLogonTimeStamp -SearchRoot '' |
where { ($_.AccountIsDisabled -eq $false) -and (($_.LastLogonTimeStamp -eq $null) -or ((((get-date) - $_.LastLogonTimeStamp).Days) -gt 90)) } |
Select-Object Name, ParentContainer, DN | Sort -Property ParentContainer| Export-Csv <file>


  1. Thanks, it's very useful information related to find all inactive computer accounts in active directory environment. I have already read many article related to this topic and then I tried this automated active directory cleanup tool ( ) that allows to find out inactive or stale computer accounts from active directory and manage inactive computer's accounts and move to another OU.


Post a Comment

Popular posts from this blog

AD LDS – Syncronizing AD LDS with Active Directory

How to increase the log retention in Orchestrator Server ( server.log)

DNS Scavenging.