Monday, December 12, 2011

How to find Inactive computer accounts in active directory?

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.
$COMPAREDATE=GET-DATE
$NumberDays=90 
$CSVFileLocation='C:\TEMP\OldComps.CSV' 
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 (http://www.lepide.com/active-directory-cleaner/) that allows to find out inactive or stale computer accounts from active directory and manage inactive computer's accounts and move to another OU.

    ReplyDelete