Retrieve Active directory disabled account by Date

Posted on 2013-11-17
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
Question by:jskfan
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
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


Author Comment

ID: 39657112
it does not display anything
LVL 53

Accepted Solution

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


Assisted Solution

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:

Author Closing Comment

ID: 39678529
Thank you Guys

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Always backup Domain, SYSVOL etc.using processes according to Microsoft Best Practices. This is meant as a disaster recovery process for small environments that did not implement backup processes and did not run a secondary domain controller that ne…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
In a recent question ( here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

696 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