Run a PowerShell script on received SMS messages

The Scripting Connector in Diafaan SMS Server can be used to run a PowerShell script for every received SMS message. The process requires the latest version of Diafaan SMS Server and the use of the .NET 4.5 platform. There are a few extra steps required to get the C# script to work.

Preparations

The first step is to add the library file ‘System.Management.Automation.dll’ to the installation folder of Diafaan SMS Server. This can be done with the following PowerShell command (this requires administrator privileges):
Copy ([PSObject].Assembly.Location) "C:\Program Files\Diafaan SMS Server"

If your system is not set up to be able to execute PowerShell scripts, or if the execution of scripts is restricted, you may have to use the following command to enable running local unsigned scripts:
Set-ExecutionPolicy RemoteSigned

Powershell commands to prepare for the C# script in the Scripting Connector

Create the PowerShell script file

We found that the best way to run a PowerShell script from Diafaan SMS Server is to wrap the script in a function with the sender number and the message text as parameters of the function:

Create a new Scripting Connector

After creating a new C# Scripting Connector you can change the script with the ‘Edit script’ link in the settings of the Scripting Connector. To enable the PowerShell functionality the top of the script must be appended with a number of lines so that it looks like this:

NewsMarch 21, 2019
Diafaan SMS Server 4.3.0.1 is available for download. This version has bug fixes for the HTTP API, the SMPP Connector and the SQL Connector.

January 21, 2019
Diafaan SMS Server 4.3.0.0 is released today. The new version contains a number of performance improvements and bug fixes.

This update adds support for encrypted SMPP connections that uses TLS 1.2 protocol in both the SMPP Gateway and the SMPP Connector. A new option to create a self-signed SSL certificate from the console program makes it easier to set up an encrypted server in one of the connectors. (change log)