Last active
September 15, 2016 19:24
-
-
Save nopslider/b23fba2b4f4a310e2cff to your computer and use it in GitHub Desktop.
Find enabled and non-locked stale AD accounts (accounts which haven't logged in for over X months. Also lists accounts which have never logged in)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-ADUser -Filter * -Properties * ` | |
| where {($_.enabled -eq $true) -and ($_.lockedout -eq $false)} ` | |
| where {$_.lastlogondate -lt (Get-Date).AddMonths(-3)} ` | |
| select SamAccountName, lastlogondate ` | |
| sort lastlogondate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment