• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 458
  • Last Modified:

Retrieve Active directory disabled account by Date

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
jskfan
Asked:
jskfan
  • 2
  • 2
2 Solutions
 
Will SzymkowskiSenior Solution ArchitectCommented:
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
 
jskfanAuthor Commented:
it does not display anything
0
 
Will SzymkowskiSenior Solution ArchitectCommented:
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
 
Pankaj_401Commented:
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
 
jskfanAuthor Commented:
Thank you Guys
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now