Asif Naeem
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)).D ate
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
I have used following script to get report new created AD user in Active directory with last 7 days.
$When = ((Get-Date).AddDays(-7)).D
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Don, I think you can improve your script by not using the System.Net.Mail.Mailmessag e object of .NET, you can directly use the "Send-MailMessage" :)
ASKER
Hi,
Thanks all three scripts very good and I have chose that suits my requirement. really appreciate all three you.
Many thanks
Thanks all three scripts very good and I have chose that suits my requirement. really appreciate all three you.
Many thanks
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
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