My PowerShell

Windows Powershell scripts, examples, tips, docs …

How to Find Inactive AD Users

Search for people who haven’t logged on to a domain in the past 180 days:

 

$180days = (get-date).adddays(-180)

 

get-aduser -filter * -properties lastlogondate | sort -property lastlogondate | Where-Object { $_.lastlogondate -le $180days } | export-csv c:\temp\inactiveUsers.csv

 

 

Tagged as:

Leave a Response