Solved

Retrieve Active directory disabled account by Date

Posted on 2013-11-17
5
434 Views
Last Modified: 2013-11-26
I need a script that retrieves Active Directory disabled accounts by Date.

for instance  smith account disabled on 02/12/2013

Any help will be very much appreciated.

Thank you
0
Comment
Question by:jskfan
  • 2
  • 2
5 Comments
 
LVL 53

Expert Comment

by:Will Szymkowski
ID: 39655310
Use the following command below to accomplish this...

Import-module activedirectory
$date = get-date 02/12/2013
get-aduser -filter * -properties * | ? {$_.enabled -eq $false -and $_.whenChanged -eq $date} | select Name, whenChanged, Enabled

Open in new window




Will.
0
 

Author Comment

by:jskfan
ID: 39657112
it does not display anything
0
 
LVL 53

Accepted Solution

by:
Will Szymkowski earned 250 total points
ID: 39657211
If the account has been modified since it was disabled then the time will change.

Use the following command and you can sort the time and easily see what accounts have been disabled during the time/day you have specificed.

get-aduser -filter * -properties * | ? {$_.enabled -eq $false} | sort -property whenChanged | select name, enabled, whenChanged

Open in new window


You can also export this to a csv as well see below...

get-aduser -filter * -properties * | ? {$_.enabled -eq $false} | sort -property whenChanged | select name, enabled, whenChanged | export-csv "c:\disabledusers.csv"

Open in new window



Will.
0
 
LVL 5

Assisted Solution

by:Pankaj_401
Pankaj_401 earned 250 total points
ID: 39660737
There is no timestamp for this specifically. Assuming the accounts haven't
been touched since you disabled them, you can look at the whenLastModified also you need to look at  two fields for this:
"userAccountControl" and "whenChanged"
In "userAccountControl" indicates a disabled account"whenChanged"should tell you when the account was disabled.
For more info look at this also: http://blogs.technet.com/b/heyscriptingguy/archive/2005/05/12/how-can-i-get-a-list-of-all-the-disabled-user-accounts-in-active-directory.aspx
0
 

Author Closing Comment

by:jskfan
ID: 39678529
Thank you Guys
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Resolve DNS query failed errors for Exchange
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question