SMS / Voice Notifications: PowerShell, System Center Operations Manager Updated

SMS / Voice Notifications: PowerShell, System Center Operations Manager Updated

February 12, 2017 0 By Morten Lerudjordet

I really like this script for sending SMS using SCOM. Though it has some bugs in it’s current form. I also do not have a Twilio account. That is why I decided to rewrite some of the logic to use generic HTTP SMS gateways. Currently it is set up for using pswincom sms gateway, though this can easily be changed to some other service. Though you will need to find out how to construct the URL for that service and change the code in the CreateSMSurl function to match.The PSWinCom details are here.

Bugs fixed:

  • Exclusion for when not to send SMS messages had some issues
  • Multiple entries on a subscriber was not handled correctly by the script
  • Fixed an issue where phone numbers was not excluded if schedule was violated
  • Removed where-object logic to make code more efficient

Now to some pointers on the SCOM configuration (tested on SCOM 2016):

  • Script will run on the members of┬áthe Notification Resource Pool in SCOM, default is all scom mgmt servers.
  • Make sure the execution policy for Powershell is set to a minimum of RemoteSigned for the script to work [Set-ExecutionPolicy -ExecutionPolicy RemoteSigned]
  • Make sure the default action account (will be used to execute the script) is local administrator on the scom management server that will run the script.
  • Run [New-EventLog -LogName $EventLog -Source $EventSource] on every server that will run the script. Where $EventLog and $EventSource are the variables set in the script, changes these out with the values there. The reason for this command is to allow the script to log to the eventlog during runtime.
  • Put the script in c:\scripts on every mgmt server member of the┬áNotification Resource Pool.
  • Create a command channel with the following settings:

    Note that this will send both alert name and description in the SMS message. Also %0a is used to add a line shift in the message. You can change this to include other content variables that SCOM supports.
  • Create a subscriber and add the SMS command channel created above to it.
  • Create subscribers that has a phone number set for the Text Message (SMS) channel type
  • Create a subscription that contains subscribers with a text message channel type, and the subscriber created above for the SMS command channel. Also add the SMS command channel on the channel tab in the creation wizard.
  • Edit the script and add your username and password for the SMS gateway.

The code: