Emailing from a PowerShell script

Send an email through your SMTP server using PowerShell

The first file (PowerShell_Email_Script.txt) gives a PowerShell script that can be used to send an email through your SMTP server.  There are extensions to the script to add attachments, that can be found online. 
 
We are using $U 6 on a Windows computer.  We are using $U to execute SQL Agent jobs, and wanted an email notification when the SQL job started running.  $U provides a email service for when the $U job completes, and this script allows us to have emails at other times. 
 
There are associated/node files that all $U to talk to and run SQL jobs.  I inserted the script in one of those .ps1 files.  Alternatively the script could be in a stand-alone .ps1 file and/or be called from the Uproc script or a .bat file.  To call the .ps1 file from the Uproc script or .bat file, see the second file (ps1_call.txt).
 
Variables passed to the file that the script is in can be used as part of the email as well, i.e. adding the SQL Agent job name to the subject line. 


 


Implementation: Add script to a PowerShell file. Add file to Uproc (associated file, node file). Call script.


Operating Systems

This plugin has no official releases yet

Created by....

A member of the Automic Community


Login to View or Leave Comments