Here’s a handy one liner to find all users in a particular OU not logged in for 90 days:

 

search-adaccount -accountinactive -usersonly -TimeSpan 90.00:00:00 -SearchBase “OU=Users,OU=Company,DC=Contoso,DC=com” | export-csv usersnotloggedinfor90days.csv

 

Hope it helps!

About the author