New User Orientation Email Script

We have a lot of new users coming and going. Some volunteers and temporary workers as well. It got a little cumbersome to relay information to their supervisors after creating accounts and doing a whole new user orientation. So… I wrote this pretty simple powershell script to take some arguments from me and email the relevant people. The users’s supervisor is their first point of contact and will give them the information. They will also find the same information in their mailbox when they get logged in (with their supervisor). I then attached a “virtual” orientation for them to use and a welcome letter with useful info. It has cut down my meeting time with them as well as subsequent calls quite a bit.

$NewUser = Read-Host -Prompt 'New Username'

$NewUserPassword = Read-Host -Prompt 'Temporary Password'

$NewUserEmail = Read-Host -Prompt 'New User Email Address'

$Extension = Read-Host -Prompt 'New User Extension'

$VoicemailPin = Read-Host -Prompt 'New User VM Pin'

$SupervisorEmail = Read-Host -Prompt 'Supervisor Email Address'

$Date = Get-Date

#introduction part of the email which changes based on above inputs.

$intro = "New Username: $NewUser | Temporary Password: $NewUserPassword | Extension: $Extension | Voicemail Pin: $VoicemailPin"

$QSGuide = "<LINK TO THE GUIDE IN HTML FORMAT>"

$recipients = $NewUserEmail,$SupervisorEmail

Write-Host "$NewUser $NewUserPassword $NewUserEmail $Extension $VoicemailPin $SupervisorEmail"

#take a moment to make sure the stuff is right.



."C:\scripts\PauseFunction.ps1"

pause

#email that stuff out

foreach ($recipient in $recipients)

{



    $smtpserver = "< YOUR EMAIL SERVER>"

    $from="<YOUR EMAIL ADDRESS>"

    $to= $recipient

    $bcc = "<IF DESIRED>"

    $subject="New User Quick Start Guide"

    $body = $intro + $(Get-Content $QSGuide|Out-String)

    $mailer = new-object Net.Mail.SMTPclient($smtpserver)

    $msg = new-object Net.Mail.MailMessage($from,$to,$subject,$body)

    $msg.IsBodyHTML = $true

    $mailer.send($msg)

}

Remove-Item function:\Pause

Here is the pause function (I didn’t write it but can’t remember where I found it): 

Function Pause($M="Press any key to continue . . . "){If($psISE){$S=New-Object -ComObject "WScript.Shell";$B=$S.Popup("Continuing will send an automated email.",0,"Script Paused",0);Return};Write-Host -NoNewline $M;$I=16,17,18,20,91,92,93,144,145,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183;While($K.VirtualKeyCode -Eq $Null -Or $I -Contains $K.VirtualKeyCode){$K=$Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")};Write-Host}