Link to home
Start Free TrialLog in
Avatar of Asif Naeem
Asif NaeemFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Script to genrate and email AD user created in last 24 hours.

Hi,

I have used following script to get report new created AD user in Active directory with last 7 days.  

$When = ((Get-Date).AddDays(-7)).Date
Get-ADUser -Filter {whenCreated -ge $When} -Properties whenCreated | Export-csv -path c:\ADLastUserCreated.csv

But Head of IT wants  me to create script  and schedule to run every 8 hours and send email on distribution group to see the report new AD created user.

i am just learning power-shell  now days and getting on this. please  Can I have help on this how to create script to genrate report and email to certine distribution group that shows last day list of AD  user created.



thanks in advance.

Regards
Asif
ASKER CERTIFIED SOLUTION
Avatar of J0rtIT
J0rtIT
Flag of Venezuela, Bolivarian Republic of image

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
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
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
Don, I think you can improve your script by not using the System.Net.Mail.Mailmessage object of .NET, you can directly use the "Send-MailMessage" :)
Avatar of Asif Naeem

ASKER

Hi,

Thanks all three scripts very good and I have chose that suits my requirement. really appreciate all three you.


Many thanks
Avatar of Naveen Sharma
Naveen Sharma

Glad it's done.
How to get a list of Active Directory user accounts created in last 24 hours: https://www.lepide.com/how-to/active-directory-accounts-created-in-past-24-hours.html