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

Report of Users accounts in Domain Controller created in Last 5 days.

Hi All,

As per requirement i have to pull a report of users accounts who has been created in last 5 days. All Domain controller are running in 2008 server.

Please share me powershell command to meet my requirement.
4 Solutions
Mike KlineCommented:
I'd have test with powershell, you can use adfind too


adfind -default -f "&(objectcategory=person)(objectclass=user)(whencreated>=20120818000000.0Z)" samaccountname whencreated -tdca

More on the format of whencreated in that query here   http://blog.joeware.net/2011/04/26/2242/

whencreated is a replicated attribute.


AhmedAliShaikAuthor Commented:
I have tried the below command

Get-ADUser -Filter {whencreated -gt $date} -properties * | ft name,whencreated

I am getting the output in the below format:
name whencreated
a        date time

Can i get the output in the below format:

Name whencreated  noofdays
A       date time         2

In the no. of days i want the substraction & know how many days back the account is created . In the output it shouls be (1 to 5)
AhmedAliShaikAuthor Commented:
Mike thanks for your response.

We are not allowed to run any tool except Microsoft in our production.

Please suggest me with the powershell or any microsoft cmdlet.

Thanks .
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Sarang TinguriaSr EngineerCommented:
Use this PS Script

Get-QADUser -CreatedAfter (Get-Date).AddDays(-5)

Open in new window

Will SzymkowskiSenior Solution ArchitectCommented:
Get-ADUser -Filter 'objectclass -eq "User"' -Properties * | Where-Object {$_.whenCreated -gt $date} | FT name,whenCreated
ThinkPaperIT ConsultantCommented:
You can also use Active Directory to do what you're looking for.

The SIMPLEST method:

Open Active Directory
Right click "Saved Queries"
Create new Query, enter a name "ALL USERS".
Click Define Query
Select the "User" tab and for "Name" select "has a value".
Click OK.

You've generated a query for "All Users".
Now select the new query you just created.
On the menu bar, select "View", "Add/Remove Columns"
Add "Created" to the list and click ok.

Then refresh your new query. It should show ALL users along with the date their account was created. You can easily export this to Excel and trim/format as needed.
AhmedAliShaikAuthor Commented:
Hi Thinkpad,

Good to know the easy step too. As per our requirement if we have a script we can automate and run a batch file, trigger an email to customer.

I have used the Quest command given by Sarang & powershell given by others aswell which are working fine.

I completely agree with your method wen we need few thinks instantly & when we are not sure about the code.

Thanks a lot.
AhmedAliShaikAuthor Commented:
Thanks All.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Worried about phishing attacks?

90% of attacks start with a phish. It’s critical that IT admins and MSSPs have the right security in place to protect their end users from these phishing attacks. Check out our latest feature brief for tips and tricks to keep your employees off a hackers line!

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