List of new AD Users in Last 7 Days
-
Hello,
I'm trying to find any and all AD users created in last 7 days. When I go to the Event Viewer and Security logs and search, there is none. However when I edit the filter and search for the last 30 days, there is also none. I know I created users two weeks ago, so I am not sure this event viewer log is functioning properly.
-
What is the best play for me to find all AD users created in last 7 days?
-
How can I get the Security logs in Event Viewer functioning properly?
Thank you.
-
-
I'm not so sure with the filtering via the GUI and event viewer but in powershell, as suggested by the microsoft document, you can do it that way.
You can also work it out logically step-by-step in powershell, as below, then save it as a .ps1 for script. Change to make it what you need...it may not work as is.
#Import the Active Directory module Import-Module ActiveDirectory # Define the date range (last 7 days) $endDate = Get-Date $startDate = $endDate.AddDays(-7) # Search for AD users created within the last 7 days $users = Get-ADUser -Filter {WhenCreated -ge $startDate} -Properties WhenCreated | Select-Object Name, SamAccountName, WhenCreated # Output the results $users | Format-Table -AutoSize
-
Thank you for the response @Ronnie-Wong . You're right, it doesn't work as is but I'll try and work with it.
-
I may be on the
wrongdifferent version of powershell.