Get a CSV file of users who haven’t logged in over 90 days with Powershell

As the title suggests, this script will query Active Directory and create a CSV file for you to review accounts that haven’t logged in in over 90 days.

get-aduser -filter 'enabled -eq $true' -Properties lastlogondate | Where-object {$_.lastlogondate -lt (get-date).AddDays(-90)} | Export-csv C:\users\public\desktop\inactive_users.csv -NoTypeInformation -Force
Travis Wade
Travis Wade
Just a normal human being living the dream. I'm an IT professional in the Healthcare space with a love and passion for cloud computing and highly redundant infrastructure.

Leave a Reply

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