Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm looking for a free or open source way to send emails to new employees when there account is created. I'm ok if its a powershell script, or something else which runs once per day. I'd like to be able to give is a couple of email files exported from outlook as there's a couple of emails I need all the new employees to get.

share|improve this question
    
Because our AD accounts are integrated with some in-house software we have we used to send an email from the software once the accounts were associated, but it would be nice to do it from the AD itself –  Mark Henderson Sep 2 '09 at 1:23

1 Answer 1

up vote 1 down vote accepted

Since the user is new and wouldn't even know their username yet, I'm not sure the following would help with alerting a new user their account has been created. However, you could schedule the following script to send emails to users. Would the script also need to determine who was recently setup or would you give it a list of usernames to send to? The following script assumes you've saved an array of user email addresses in $userlist.

foreach($user in $userlist) {
   $exportedmessage = "message.eml"    
   $smtpServer = “localhost”
   $msg = new-object Net.Mail.MailMessage
   $att = new-object Net.Mail.Attachment($exportedmessage)
   $smtp = new-object Net.Mail.SmtpClient($smtpServer)
   $msg.From = “admin@yourdomain.com”
   $msg.To.Add(”newuser@theirdomain.com”)
   $msg.Subject = “Welcome to the Company”
   $msg.Body = “Here is some important information you should keep handdy.”
   $msg.Attachments.Add($att)
   $smtp.Send($msg)
}

Save this code as welcome-newuser.ps1. To schedule this task, follow the directions outlined here: http://www.searchmarked.com/windows/how-to-schedule-a-windows-powershell-script.php

If you use the free Active Directory cmdlets from Quest (http://www.quest.com/powershell/activeroles-server.aspx) you can use the following PowerShell code to find users created 24 hours prior to "now".

$then = (get-date).AddDays(-1)
get-qaduser | where { $_.creationdate -gt $then } | select email
share|improve this answer
    
A lot of our users aren't on the domain, so he give them Webmail information. These emails are for things like how to change your password via OWA, how to setup Outlook to hit OWA, etc. Any idea how to get a list of users from AD that were created yesterday? –  mrdenny Sep 2 '09 at 6:59
    
I updated my answer to include code for retrieving the list of users created yesterday. –  Marcus Sep 2 '09 at 20:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.