Mundy

IT Knowledge Base

User Tools

Site Tools


Sidebar

Contact me at dan@mundy.co for any feedback or suggestions.


My other sites:

Search all my sites:

find_inactive_user_accounts

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)