Link to home
Start Free TrialLog in
Avatar of amazon4life
amazon4life

asked on

PowerShell Script - List users that have not logged on in the past 3 months

Does anyone have a PowerShell script that can list users in AD that have not logged on in the past 3 months?
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

import-module ActiveDirectory
Search-ADAccount -AccountInactive -TimeSpan 90.00:00:00 | where {$_.ObjectClass -eq 'user'} | FT Name,ObjectClass –A

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Niten Kumar
Niten Kumar
Flag of Fiji image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You can also try the following script:

Search-ADAccount -AccountInactive -TimeSpan 90.00:00:00 | ?{$_.enabled -eq $true} | %{Get-ADUser $_.ObjectGuid} | select name, givenname, surname | export-csv c:\report\unusedaccounts.csv -NoTypeInformation