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

Posted on 2012-08-23
Last Modified: 2012-08-26
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.
Question by:AhmedAliShaik
    LVL 57

    Assisted Solution

    by:Mike Kline
    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

    whencreated is a replicated attribute.


    LVL 2

    Author Comment

    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)
    LVL 2

    Author Comment

    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 .
    LVL 18

    Accepted Solution

    Use this PS Script

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

    Open in new window

    LVL 53

    Assisted Solution

    by:Will Szymkowski
    Get-ADUser -Filter 'objectclass -eq "User"' -Properties * | Where-Object {$_.whenCreated -gt $date} | FT name,whenCreated
    LVL 16

    Assisted Solution

    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.
    LVL 2

    Author Comment

    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.
    LVL 2

    Author Closing Comment

    Thanks All.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
    New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
    This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…
    This tutorial will walk an individual through the steps necessary to configure their installation of BackupExec 2012 to use network shared disk space. Verify that the path to the shared storage is valid and that data can be written to that location:…

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now