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

2017-12-08T14:27:03+00:00 March 30th, 2016|PowerShell|

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!