Powershell : Find all active users who havent logged in

Request from a customer. Find me all active ( IE not disabled ) users in a particular OU who have never logged in.

“I have a powershell for that” appears to be the default answer for most queries these days …

Get-ADUser -Filter {enabled -eq $true} -SearchBase "OU=Eu,DC=eu,DC=notyou,DC=com" -Properties "LastLogonDate" | sort-object -property lastlogondate -descending |Format-Table -property Name, sAMAccountName, LastLogonDate -AutoSize >>c:temptestoutput.csv

Leave a Reply

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