Send text messages (SMS) using Windows PowerShell
In Microsoft Office Outlook there is an add-in called Microsoft Outlook SMS Add-in (MOSA), which provides the ability to send text messages (SMS). MOSA is builtin to Outlook 2010, and are available as a plugin for Outlook 2003 and 2007 here.
On the Microsoft Office Online Help you can find guidance on how to set up the service account and sending a text message. To find the necessary settings for your mobile service provider, go here.
I looked into the COM-object for Outlook, and it turned out to be rather easy to use this API to send text messages from MOSA.
Based on that I created an Advanced function in Windows PowerShell v2 called Send-SMSMessage.
To define the function you can either paste it directly into your session, save it as a ps1 script-file and dot source it, put it into your profile or into a module.
When that is accomplished you can find usage information using the consistent Get-Help cmdlet:
Sample usage:
The function checks if Outlook are installed, and breaks out with a warning if not:
It also checks to see if an account are configured for Text Messaging (SMS):
Any errors related to service availabilty, correct phonenumber format and so on are handled by the SMS Add-in itself. These error messages appear in the Outlook inbox:
The function is tested from Outlook 2010 only, but should work from 2003 and 2007 also when MOSA is installed.
Since the function accepts ValueFromPipeline and ValueFromPipelineByPropertyName you can use it in conjunction with e.g. the Active Directory cmdlets for Windows PowerShell. A given example of this retrieves all users from Active Directory with a derfined mobilephone number and sends them an SMS with their username:
Another practical usage scenario I can think of is combining the Send-SMSMessage function with user provisioning, sending the new user it`s new username and password.
Feel free to come up with more usage scenarios in the comment field below.
Bonus tips
- You can also send MMS messages using the Outlook COM-object. To do this, use “olMobileItemMMS” instead of “olMobileItemSMS” in the following line: $NewMessage = $outlook.CreateItem(“olMobileItemMMS”). You should also look into the other properties for MMS messages, like the Attachment-property.
- If you got more than one account configured for text messaging, you can use the SendUsingAccount-property to define which account to send from.
- If you use the Norwegian mobile service provider Telenor, the “Service Provider URL” in the account settings is https://telenormobil.no/smapi/services/omsv3_service
July 21, 2010 Posted by Jan Egil Ring | Active Directory management, Microsoft Outlook, Scripting, Windows PowerShell | powershell send sms, powershell send text message, sms from powershell | 10 Comments
About
Jan Egil Ring works as a Senior Consultant on the Infrastructure Team at Crayon, Norway.
He mainly works with Microsoft server-products, and has a strong passion for Windows PowerShell. In addition to being a consultant, he is a Microsoft Certified Trainer.
He has obtained several certifications such as MCITP: Enterprise Administrator and MCITP: Enterprise Messaging Administrator. For more details see his MCP Virtual Business Card.
In January 2011, he was awarded the Microsoft Most Valuable Professional Award for his contributions in the Windows PowerShell technical community.
His engagements as a speaker includes TechDays in Norway, as well as a Microsoft Office 365 bootcamp for Microsoft partners in Norway.
He is a co-founder of the Norwegian Microsoft Technology User Group (MTUG), which is an assosication of local MTUG user groups in Norway.
His intentions with this blog is to share experiences based on various projects and troubleshooting, as well as sharing different resource links to technologies he works with.
Blogroll
Google Reader – My Shared Items- Kill cmd.exe Bartek Bielawski
- SCVMM 2012 Quick Tip: Finding which storage arrays a Hyper-V host can see hector.linares
- On Becoming a Senior Technical Individual Contributor jsnover
- Fix for "You must close all dialog boxes before you can close Exchange Management Console" in Exchange 2010 Jeff
- The Windows 8 Task Manager Steven Sinofsky
Category Cloud
Active Directory management Deployment Desktop management Exchange 2003 Exchange ActiveSync Exchange Server 2007 Exchange Server 2010 Exchange Server management General Group Policy Hyper-V Hyper-V R2 MDT 2010 Migration Print management Remote Desktop Services Remote Management SBS 2008 Scripting Server management Terminal Services Usergroups Virtualization Windows 7 Windows PowerShell Windows Server 2003 R2 Windows Server 2008 Windows Server 2008 R2 Windows Vista Windows XP
-
Top Posts
My tweets
- @fodinsen Wohoo :-) 1 day ago
- @JohnACook @alexandair @powerscripting Thanks for the RT! 2 days ago
- I just blogged: Getting information about Run As Accounts for services and scheduled tasks: On a default Windows... http://t.co/fTgY3T1E 3 days ago
- “RT New on #PSMag: Windows PowerShell sessions from Nordic Infrastructure Conference 2012 available http://t.co/cdceQzZ5” #NICconf 1 week ago
- I just blogged: Demos, slides and videos from Nordic Infrastructure Conference 2012 sessions: On January 13th – ... http://t.co/x29EYBqN 2 weeks ago
Personal links
-
Blog Stats
- 389,387 hits




