Link to home
Start Free TrialLog in
Avatar of Adrian Gillott
Adrian Gillott

asked on

Getting the number of user accounts in Active Directory on a specific date

I'm using:
get-aduser -filter 'enabled -eq $true' | measure-object | select-object count

Which is great, but is there a means to get an enabled user count for a specific date in the past? I'm attempting to find out how many active users we had on specific dates throughout the year.
SOLUTION
Avatar of ferrarista
ferrarista

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
Avatar of ITSysTech
ITSysTech

So you could use this to find newly added users,

$When = ((Get-Date).AddDays(-30)).Date
Get-ADUser -Filter {whenCreated -ge $When} -Properties whenCreated

And change -30 to when ever the time was so three months ago would be -90 .

Or change whenCreated to what ever your looking for.

EXAMPLE:

$When = ((Get-Date).AddDays(-30)).Date
Get-ADUser -Filter {Enabled -ge $When} -Properties Enabled



For users:
$When = ((Get-Date).AddDays(-30)).Date
Get-ADUser -Filter {whenCreated -ge $When} -Properties whenCreated

For Groups:
$When = ((Get-Date).AddDays(-30)).Date
Get-ADGroup -Filter {whenChanged -ge $When} -Properties whenChanged

Edit: To make things easier I would use AD Explorer. Linky This is a very powerful search program for AD.
ASKER CERTIFIED SOLUTION
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 cannot do it with standard Active Directory tools.
Using whenCreated or whenChanged attribute to query AD will not produce the most accurate result because it will not show deleted users.