• Blog
  • Webinars
  • Partner
  • Support
  • Contact
ScriptRunner
  • About us
    • Team
    • Jobs
    • Press
  • Why
  • Use Cases
  • Software
    • ScriptRunner Server
    • ScriptRunner Web Apps
    • ScriptRunner Connectors
    • ScriptRunner ActionPacks
  • Try Now
  • Search
  • Menu Menu
You are here: Home1 / ScriptRunner Blog2 / Automation3 / E-mail notification in ScriptRunner

E-mail notification in ScriptRunner

Author: Frank Kresse, Head of Product | Reading time: 3 minutes | Category: Automation

Email notification in ScriptRunner

This article has been translated automatically.

It is often desired that administrators or other users should be informed about the execution of an automation task. In addition to pure status information, this also involves the notification of results or errors.

ScriptRunner Notifications can be sent per action in case of success, error or always to a defined group of people. ScriptRunner currently offers the e-mail notification function for this purpose. The working method is shown schematically in the figure.

  • Preparations
  • Query configuration
  • Setting the E-Mail Notification Connector
  • Creating and Applying a Secure String for Password
  • Testing the E-Mail Notification Connector
  • Use e-mail notifications to actions

To be able to use e-mail notifications with ScriptRunner, the e-mail notification connector must be put into operation. The settings for this fall under the global configuration of the ScriptRunner Service Host and are made using the PowerShell ScriptRunnerSettings module.

The user of the module must have appropriate access and system rights for the operating system on the ScriptRunner Service Host. These rights are independent of the membership in the role ScriptRunner Administrators.

The module maps the following functional areas for the global settings:

  • licensing
  • Connections for license activation via Internet proxy
  • Script Library Directory and Archive Function
  • directly usable PowerShell modules
  • SQL connection string to external reporting/auditing database
  • ScriptRunner Service
  • E-mail Notification Connector
  • E-Mail Inbound Connector

All cmdlets can be queried using Get-Command modules ScriptRunnerSettings.

Preparations

ScriptRunner Service Host can send emails over an SMTP connection. The following information is required for configuration:

  • Name of the SMTP server
  • port
  • Use of TLS yes/no
  • Authentication: anonymous user or named user (username, password)
  • E-Mail Sender Address
  • CC Receiver Addresses

Query configuration

The basic settings of the E-Mail Notification Connector can be queried with the command Get-ASREMailNotificationConnector -verbose. After the setup some usual settings have already been made, which do not necessarily have to correspond with the situation in the environment!

Setting the E-Mail Notification Connector

The setting is done with the command Set-ASREMailNotificationConnector. The following parameters are important and can also be used individually with the command:

  • On: switches the connector ON
  • Off: switches the connector OFF
  • Host: the FQDN or the IP address of the machine with the SMTP service.
  • Port: Port of the SMTP service on the machine.
  • UseTLS: use TLS for communication yes/no
  • Mailbox account: Username, which may send via SMTP
  • Password: Password for the user name as PowerShell Secure String OR
  • ClearPassword: Password as plain text
  • UseMailboxAsSender: the mailbox of the user is used. Its e-mail address is used as the sender address. Sent e-mails are stored as sent e-mails in the mailbox (system-dependent).
  • Sender: Sender e-mail address if UseMailboxSender=no
  • CCSender: the e-mail is sent to the sender in CC.
  • Restart: Restart the ScriptRunner service to make the configuration effective.

Creating and Applying a Secure String for Password

Enter the following command in the PowerShell ISE:

C:users…>$SecPwd = ConvertTo-SecureString -String ‘mypassword’ -AsPlainText -Force

The $SecPwd variable then contains the password. This can now be used within the session in (any) command line.

C:users…>Set-ASREMailNotificationConnector -MailboxAccount MyAccount -Password $SecPwd

Example 1 – anonymous shipping

If the notifications are to be sent using the SMTP settings “Anonymous”, the ScriptRunner Host must be authorized as an anonymous sender in the mail system.

The following settings would have to be made for this:

  • Host: MyMailserver.corp
  • Port: 25 OR 587
  • Use TLS: yes OR no (depending on port)
  • Transmitter: ScriptRunner@corp.com
  • CCSender: no (default) OR yes, if a mailbox for ScriptRunner exists on another mail system

Then use the options -On and -Restart as well as -Verbose to activate it.

Example 2 – Exchange

If the notifications are to be sent via Exchange Server, it must be possible to log on to an Exchange mailbox from the ScriptRunner host.

The following settings would have to be made for this:

  • Host: MyExchangerServer
  • Port: 587 OR 25
  • Use TLS: yes OR no (depending on port)
  • Mailbox account: User name for the Exchange mailbox
  • Password: Password for the user as PowerShell Secure String OR
  • ClearPassword: Password in plain text
  • UseMailboxAsSender: yes

Then use the options -On and -Restart as well as -Verbose to activate it.

Example 3 – Office 365

If notifications are to be sent via Office 365 Exchange Online, it must be possible to log on to Exchange Online from the ScriptRunner host.

The following settings would have to be made for this:

  • Host: smtp.office365.com
  • Port: 587
  • Use TLS: yes
  • MailboxAccount: complete mail address of the Office365 user
  • Password: Password for the user as PowerShell Secure String OR
  • ClearPassword: Password in plain text
  • UseMailboxAsSender: yes

Then use the options -On and -Restart as well as -Verbose to activate it.

Testing the E-Mail Notification Connector

The connector test only checks the settings and the logon to the SMTP service. No test mail will be sent.

The test is performed with the command Test-ASREMailNotificationConnector. The password has to be entered. The following variants can be used with the command:

  • Password: Password for the user name as PowerShell Secure String OR
  • ClearPassword: Password as plain text

When testing Anonymous SMTP connections no password is required!

Check connector settings in the ScriptRunner Admin App

The settings for the E-Mail Notification Connector can be viewed with the ScriptRunner Admin App. Changes can be made with the PowerShell module ScriptRunnerSettings.

If changes made are not yet visible in the admin app, the ScriptRunner service on the host should be restarted with the Restart-ASRService command.

Use e-mail notifications to actions

A notification in ScriptRunner is always assigned to a specific action and consists of four essential elements:

  • Trigger for a Notification Message
  • Contents of a Notification Message
  • Receiver of a notification message
  • Output channel of a message

For e-mail notifications, the output channel is the e-mail notification connector.

Alternative triggers for an e-mail notification message can be:

  • The execution of the action generated an error.
  • The execution of the action was successful.
  • The action is complete, whether successful or with an error.

The receivers of a notification message can be defined for each action in the action wizard. To do this, select the action and click the EDIT button in the Action Bar (below). Then select the Wizard page Set Result Options & Notifications.

To test, execute the action and select and open the mail in the mailbox (please also check spam folder).

The e-mail contains a simple short report in the body and the PowerShell Report as an attachment.

If you have questions about the E-Mail Notification Connector or about ScriptRunner in general, you can contact us via our contact form or at info@scriptrunner.com.

Share this article
  • Share on Facebook
  • Share on Twitter
  • Share on LinkedIn
  • Share on Reddit
  • Share by Mail

You might also be interested in these posts:

Closeup of a person in a hammock with their legs crossed

2020 – Finally, the year of IT automation?

30. March 2020
Read more
https://www.scriptrunner.com/wp-content/uploads/2020/03/2020-year-of-automation.jpg 1000 1000 Heiko Brenn, Head of International Business https://www.scriptrunner.com/wp-content/uploads/2018/05/ScriptRunner_Logo_RGB-300x45.png Heiko Brenn, Head of International Business2020-03-30 16:13:282021-01-13 14:51:332020 – Finally, the year of IT automation?
Webinar: Administrate PowerApps and Automate (aka Flow) efficiently with PowerShell

ScriptRunner ActionPack for Microsoft Power Apps and Power Automate

14. January 2020
Read more
https://www.scriptrunner.com/wp-content/uploads/2020/01/1zu1.png 702 702 Aline Imhof https://www.scriptrunner.com/wp-content/uploads/2018/05/ScriptRunner_Logo_RGB-300x45.png Aline Imhof2020-01-14 15:38:492021-01-14 16:55:03ScriptRunner ActionPack for Microsoft Power Apps and Power Automate
PowerShell Scripts Automation

Using PowerShell Scripts for Automation

15. August 2019
Read more
https://www.scriptrunner.com/wp-content/uploads/2019/08/PowerShellScripte_2zu1-e1581605646278.png 286 441 Thomas Joos https://www.scriptrunner.com/wp-content/uploads/2018/05/ScriptRunner_Logo_RGB-300x45.png Thomas Joos2019-08-15 00:04:432021-01-14 14:12:55Using PowerShell Scripts for Automation

About the author:

Frank Kresse, Head of Product

Frank Kresse is the Head of Product. As the inventor of the automation and delegation solution for PowerShell, he advises clients on use case scenarios and develops solutions for the automation and the digitalization of their processes. He is also involved in technology start-ups.

Latest posts:

  • Article: X-mas Fun with PowerShell and ScriptRunnerScriptRunner Software GmbHX-mas Fun with PowerShell and ScriptRunner23. December 2020 - 10:00
  • ScriptRunner Software GmbHUsing PowerShell to Create New Citrix MCS Machines15. December 2020 - 16:25
  • Article: An Introduction to PowerShell in Citrix Virtual Apps and DesktopsScriptRunner Software GmbHAn Introduction to PowerShell in Citrix Virtual Apps and Desktops7. December 2020 - 17:01
  • Article image: PowerShell AliasingScriptRunner Software GmbHPowerShell Aliasing2. December 2020 - 10:00
  • Article image: ScriptRunner sponsors Scottish Summit 2021ScriptRunner Software GmbHScriptRunner sponsors the Scottish Summit 202125. November 2020 - 10:00

Product

  • ScriptRunner Platform
  • ScriptRunner Server
  • ScriptRunner Apps
  • ScriptRunner Connectors
  • Script Collections
  • Licensing
Get your free trial

Solutions

  • IT Administrators
  • IT Team Leaders
  • Use Cases

Resources

  • Blog
  • Documentation
  • Knowledge Base
  • Webinars
  • PowerShell Lexicon
  • PowerShell Poster
  • PowerShell Security Ebook

Company

  • About us
  • Team
  • Jobs
  • Press
  • References
  • Partner

Contact

ScriptRunner Software GmbH
Ludwig-Erhard-Straße 2
76275 Ettlingen
Germany

T: +49 7243 20715-0
M: info(at)scriptrunner.com

Request Demo
© ScriptRunner Software GmbH is a subsidiary of AppSphere AG
  • LinkedIn
  • Xing
  • Twitter
  • Facebook
  • Youtube
  • Imprint
  • Privacy Policy
  • Newsletter
Bulk Actions Made Easy with PowerShell and ScriptRunner Bulk Actions with PowerShell and ScriptRunner Secure use of credentials in PowerShell in ScriptRunner Secure use of credentials in PowerShell with ScriptRunner
Scroll to top