Bart Simons

Bart Simons

Thoughts, stories and ideas.

Bart Simons



.net .net 5 .net core Apache C# CentOS LAMP NET Framework Pretty URLs Windows Server WireGuard access log add analysis android api at the same time authentication authorization automate automation azure azurerm backup bash basics batch bootstrap build capture cheat sheet chromium chroot class cli click to close code coverage code snippet command line commands compile compiling compression containers control controller controlling convert cpu usage create credentials csv csvparser curl data dd deployment desktop detect devices disable diskpart dism distributed diy docker dom changes dotnet core drivers ease of access encryption example export file transfer files fix folders framework generalize getting started ghost gui guide gunicorn gzip html html tables icewarp igd imagex import inotify install installation interactive ios iphone itunes java javascript jquery json kiosk kotlin linux live load data loading screen lock screen loopback audio lxc lxd lxml macos manage manually message messages minio mirrored mod_rewrite monitor monitoring mstest mutationobserver mysql net 5 nexmo nginx no oobe node node.js nodejs not installing notification notifications object storage on desktop one command openssl owncloud parallels parallels tools parse perfect philips hue play port forwarding powershell processing ps-spotify python quick raspberry pi record rip ripping rsync rtmp save save data sbapplication scraping script scripting scriptingbridge scripts security send server service sharedpreferences sms songs sonos spotify spotify api spotlight ssh stack streaming streamlink studio sudo swarm swift sync sysprep system audio systemd tables terminal testing tracking tutorial twilio ubiquiti ubuntu ubuntu 18.04 ui code unifi unlock unsplash source upnp uptime usb tethering wallpapers wasapi website websites webview windows windows 10 without itunes without oobe workaround xaml

Send SMS messages with PowerShell


Programmatically sending SMS messages is easier than ever before. Companies like Nexmo and Twilio have been providing businesses with communication APIs that are so easy to implement in your current software that even the lowest skilled developers can work with it. The big disadvantage of all these services is that each provider has their own API specification.

Since I do a lot of my automation scripting with PowerShell, I decided to write a simple and easy-to-use PowerShell module to send SMS with one command. You - the developer - only have to specify the provider, recipient, sender and message. It can't get any easier!

Source code on GitHub

You can find the source code on GitHub:

Installation guide

Install PowerShell-SMS with this script that you have to copy-paste into your PowerShell window:

If ([Environment]::OSVersion.Platform -eq "Unix") {
    $ModulePath = [Environment]::GetEnvironmentVariable("PSModulePath").split(":")[0]
    If (Test-Path "$ModulePath/"){Remove-Item "$ModulePath/"}
    If (Test-Path "$ModulePath/PowerShell-SMS"){Remove-Item "$ModulePath/PowerShell-SMS" -Confirm:$false -Recurse -Force}
    Invoke-WebRequest -OutFile "$ModulePath/"
    Expand-Archive "$ModulePath/" -DestinationPath "$ModulePath"
    Remove-Item "$ModulePath/"
    Get-ChildItem "$ModulePath" | where { $_.Name -like "bmsimons-PowerShell-SMS*" } | % { Move-Item -Path ("$ModulePath/"+$_.Name) -Destination "$ModulePath/PowerShell-SMS" }
} Else {
    $ModulePath = [Environment]::GetEnvironmentVariable("PSModulePath").split(";")[0]
    If (Test-Path "$ModulePath\"){Remove-Item "$ModulePath\"}
    If (Test-Path "$ModulePath\PowerShell-SMS"){Remove-Item "$ModulePath\PowerShell-SMS" -Confirm:$false -Recurse -Force}
    Invoke-WebRequest -OutFile "$ModulePath\"
    Expand-Archive "$ModulePath\" -DestinationPath "$ModulePath"
    Remove-Item "$ModulePath/"
    Get-ChildItem "$ModulePath" | where { $_.Name -like "bmsimons-PowerShell-SMS*" } | % { Move-Item -Path ("$ModulePath\"+$_.Name) -Destination "$ModulePath\PowerShell-SMS" }

If you get an error, please use the open-source PowerShell version and run as admin if your modules folder is inaccessible by non-admins.

Cool, now you are ready to go!

Please note that documentation of this module is available on my GitHub repository. I am demonstration the use of Nexmo as a SMS API provider in this post so in case you want to learn more about other providers and their configuration parameters: check out my GitHub repository for a detailed guide on other SMS API providers.

Let's get started by configuring everything:

# Import the PowerShell-SMS module
Import-Module PowerShell-SMS

# Set the API key and API secret for Nexmo (this will be used for authentication)

# Send an SMS message to the recipient
Send-SMS -Provider Nexmo -From SENDERGOESHERE -To RECIPIENTGOESHERE -Message "Hello from PowerShell!"

Nexmo Send SMS

The recipient should receive the SMS message in no time:

Nexmo Receive SMS

Bart Simons

Bart Simons

View Comments