Powershell one-liner to find all users in an OU not logged in for a time span

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!

Post to Twitter

Leave a Comment

Your email address will not be published. Required fields are marked *