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:

image

Sample usage:

image

The function checks if Outlook are installed, and breaks out with a warning if not:

image

It also checks to see if an account are configured for Text Messaging (SMS):

image

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:

image

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:

image

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

Outlook signature based on user information from Active Directory

To provide a consistent company image all users should use the same signature template in their Outlook profile. Ive created a Windows PowerShell-script to deploy a consistent Outlook signature to users, based on user information retrieved from Active Directory. Ive used the fields “Display name”, “Title, “E-mail” and “Telephone number”, however, additional fields may be added to suit your needs.

 

Step-by-step

1) Download the script from here. Save it to a UNC-path accessible for all users.

2) Adjust the custom variables:

image

3) From an Outlook client, create a signature based on your company template:

image

4) Copy the signature files from %appdata%MicrosoftSignatures to the UNC-path specified in the SigSource-variable in the script:

 

image

 

5) Open both Company Name.rtf and Company Name.htm in Microsoft Office Word and insert the following bookmarks:

image

Mark each word, e.g. “EmailAddress”, go to “Insert”, press the “Bookmark”-button and name the bookmark “EmailAddress”. It`s important that the names of the bookmarks are “DisplayName”, “Title”, “TelephoneNumber” and “EmailAddress”.
This is because these bookmarks are replaced by the information retrieved from Active Directory for the logged-on user.

6) When appropriately tested, deploy the script to end users. This may be accomplished by e.g. Group Policy:

image

 

Additional information

Sample signature created using Set-OutlookSignature.ps1:

image

Active Directory object for sample user:

image image

 

Settings are stored in HKCU in the registry:

image

A few notes:
-Existing signatures are preserved
-Users are allowed to make customizations to their signatures until a new version are deployed. Then the exisiting company-signature will be overwritten.

 

Update 21.11.2010: The script are improved by Darren Kattan. For details and updated instructions, see this blog-post.