IT Knowledge Base

User Tools

Site Tools


Contact me at for any feedback or suggestions.

My other sites:

Search all my sites:


Find inactive user accounts

  • Show all accounts that have not logged on in the last 60 days:
    PS H:\> Search-ADAccount -AccountInactive -TimeSpan 60.00:00:00 | where {$_.ObjectClass -eq 'user' -and $_.Enabled -eq 'True'} | ft SamAccountName,Name,LastLogonDate
  • Show all accounts, sorted by last logon date:
    Get-ADUser -Filter {Enabled -eq $true} -Properties Name,Manager,LastLogon | Select-Object SamAccountName,Name,@{n='LastLogon';e={[DateTime]::FromFileTime($_.LastLogon).ToString('yyyy-MM-dd')}} | Sort LastLogon

find_inactive_user_accounts.txt · Last modified: 2018/04/09 09:56 (external edit)