Send Text and Email to User from Task Sequence

Bonus: Learn to use Gmails SMTP service.

Updated 1/31/2019 - Updated Script to work independently of XAML Form, you can use the last script to send text / email by running the script and using arguments: SendTextEmail.ps1 -UserEmail -UserCell 6512015555 -UserCellProvider Verizon

Updated 3/6/2018 - added auto close feature, so if user ignores the window, it will auto close allowing the TS to continue. (Updated the 3rd Form image below to reflect the change)

Or if some of you awesome PowerShell guys want to make my code pretty and add that feature...  🙂

As I try to improve the user experience for in-place upgrades, notifications came to mind, and how to incorporate that into the process.  Using the TS variable _SMSTSUserStarted = true, I launch a powershell driven “front end” to collect the user’s email, cell number & provider, then use that to notify user when process is complete.


Using @FoxDeploy’s guide and a little help over twitter, I was able to create a form to collection the information.

The form launches, to ask for the email, then check a box, if you check the box, it un-hides the rest of the form required for the text, and also “greys-out” the “OK” button, until the required information is collected.


Once the user inserts their Cell Number & selects a
radio button, the Ok button lights back up, and they can choose OK.  The Skip button just closes the form allowing the TS to continue with no data collected.

Once you click OK, the Data goes into the registry & into TS Variables.  I add it to the registry because I want it there for the next upgrade.  When the form loads, it will look for those keys, if they are there, it will auto populate, allowing the user to then click OK, or modify first, and then continue.

Code for Form:


TS Step for Form:

Code from Command Line: *NOTE, requires ServiceUI.exe in the same package as the scripts:


At the end of the TS, there is a last step that runs another script that will grab the variables and send the email and text.  Currently I’m using Gmail’s SMTP service to do it, I created a new gmail account and set the required changes needed to use it to relay SMTP email. Instructions HERE - Follow the instructions for use Gmail SMTP Server, which requires you to first set "Less Secure Apps" is enabled for the account. The username & password are in clear text in my script, feel free to modify it to use a more secure method, like a password file, or use an internal SMTP server that doesn’t require authentication.

Why the radio buttons for the carrier?  Most carriers have a way to send text using an email address.  I use this feature to append the email address suffix onto the cell number and send the email to that cell phone’s SMS email address, so it comes in as a text.  If your carrier isn’t listed, you can probably look it up on their website.  Example, I use Boost Mobile, which is on the Sprint Network, in my testing, using my cell number and the Sprint’s email, it would send me the text.  You can probably just google it too..

Code for Script:


Step in TS:

Feel free to skip the user interaction part, and just hardcode the script to send a text or email to a specific person for every upgrade / OSD deployment, like your boss, so you can prove how often you upgrade a machine successfully, I’m sure the sentiment will be of Awe, and not annoyance.


As always, please leave a comment or hit me up on twitter.  I only tested sending text messages to Boost Mobile & Verizon, but I ASSUME rest of them will work.  If you find any problem, please leave a comment to help others.


PS.. please forgive my powershell code, I’m still learning, and most of it is thanks to googling and trial and error.

4 thoughts on “Send Text and Email to User from Task Sequence”

  1. Just what I was looking for!

    For my purpose at an MSP, I needed a script to run in WinPE (using MDT) during the question file portion, ask for the technician's e-mail, and/or phone number, to let them know when a deployment was complete. I made a few modifications to send the e-mail to our Exchange server. To save the variables in WinPE, you do need to dump the variables to the variables.dat file, which is detailed here:
    Other than that, great script!

  2. Hi,
    We have a been using a script which does a different role to this, as it offers a menu to install a chosen language pack, unfortunately, since upgrading to SCCM 1806, the menu has stopped appearing? It looks like it could be down to the xmlnodereader not loading, any ideas to help us try an fix the issue?


Leave a Reply to Vic D. Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.