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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
Using whenCreated or whenChanged attribute to query AD will not produce the most accurate result because it will not show deleted users.
$When = ((Get-Date).AddDays(-30)).
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)).
Get-ADUser -Filter {Enabled -ge $When} -Properties Enabled
For users:
$When = ((Get-Date).AddDays(-30)).
Get-ADUser -Filter {whenCreated -ge $When} -Properties whenCreated
For Groups:
$When = ((Get-Date).AddDays(-30)).
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.