Export last logon time for all users in Active Directory

Perhaps time to clean up your Active Directory? Need to check when your users last logged on?

Get-ADUser -Filter {(employeeID -like "*") -And (Enabled -eq $true)} -Properties LastLogonTimeStamp |
Select-Object Name,@{Name="LastLogonTimeStamp"; Expression={[DateTime]::FromFileTime($_.lastLogonTimestamp).ToString('yyyy-MM-dd-HH:mm:ss')}} | Export-Csv -Force -Path $env:USERPROFILE\Desktop\$(get-date -f yyyy-MM-dd-HH-mm-ss)-LastLogonTime.csv -Encoding Unicode -NoTypeInformation

The time format here could probably be adjusted for easier sorting in Excel, but I have not had the time for that yet.

If you just want a “one-liner” to check on a single user you can do

Get-ADUser -Identity "USERNAME" -Properties "LastLogonDate" | select LastLogonDate