Mundy

IT Knowledge Base

User Tools

Site Tools


find_inactive_user_accounts

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
find_inactive_user_accounts [2018/01/19 10:10]
Dan Mundy
find_inactive_user_accounts [2018/04/09 09:56] (current)
Line 1: Line 1:
 ====== Find inactive user accounts ====== ====== Find inactive user accounts ======
  
-  * Show all accounts that have not logged on in the last 60 days:<​code>​PS H:\> Search-ADAccount -AccountInactive -TimeSpan 60.00:00:00 | where {$_.ObjectClass -eq '​user'​ -and $_.Enabled -eq '​True'​} | ft SamAccountName,​Name,​LastLogonDate</​code>​ +  * Show all accounts that have not logged on in the last 60 days:<WRAP prewrap>​ 
-  * Show all accounts, sorted by last logon date:<​code>​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</​code>​+<​code ​powerhell>PS H:\> Search-ADAccount -AccountInactive -TimeSpan 60.00:00:00 | where {$_.ObjectClass -eq '​user'​ -and $_.Enabled -eq '​True'​} | ft SamAccountName,​Name,​LastLogonDate</​code
 +</WRAP
 +  * Show all accounts, sorted by last logon date:<WRAP prewrap>​ 
 +<​code ​powerhell>​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</​code
 +</WRAP>
  
 {{page>​ad&​noeditbutton&​nofooter}} {{page>​ad&​noeditbutton&​nofooter}}
- 
-<WRAP prewrap> 
-<code powerhell>​ 
-Search-ADAccount -AccountInactive -TimeSpan 60.00:00:00 | where {$_.ObjectClass -eq '​user'​ -and $_.Enabled -eq '​True'​} | ft Name 
-</​code>​ 
-</​WRAP>​ 
- 
-Source: [[https://​technet.microsoft.com/​en-us/​library/​dd391899(v=ws.10).aspx|Finding Users Who Have Not Logged on Recently]] 
find_inactive_user_accounts.txt · Last modified: 2018/04/09 09:56 (external edit)