Monday, December 12, 2011

Do you know how can we do this? Either we query the AD to get the information by writing code in C# or manually check the AD for the inactive accounts. But, there is another simple way which will get this information without any big efforts. Yes, using Powershell script.
GET-QADCOMPUTER -SizeLimit 0 -IncludedProperties LastLogonTimeStamp | where { ($CompareDate-$_.LastLogonTimeStamp).Days -gt $NumberDays } | Select-Object Name, LastLogonTimeStamp, OSName, ParentContainerDN | Sort-Object ModificationDate, Name | Export-CSV $CSVFileLocation 
You have to provide the days - the timeline of inactive accounts and where to save the output of inactive accounts list.

The complete information is available at this post.

1 comment:

  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.