Monday, March 30, 2015

Getting Other Types of "Things" from a Custom PowerShell Exchange Connector

9:35 PM Posted by Adam Dzak No comments

You know what seems like a reasonable thing to do? Call a phone number, leave a voicemail, and create an incident for the user that called; to the shell!

Scenario: Your company makes use of a non-Microsoft phone system and you've setup a phone number to leave voicemails in the Service Manager Workflow account's inbox so as to take advantage of the Exchange Connector with the purpose of converting the email with voicemail attachment to a Work Item (Incident or Service Request) within SCSM.

Issue: The Exchange Connector (v3 and 3.1) both only parse a specific type of message class. That message class is "IPM.Note". It's by design and crazily useful because it means only emails will get converted into Work Items. Things that won't get converted are things like Out of Office replies (IPM.Note.Rules.Oof.Template.Microsoft) or in this case your phone system's more than likely proprietary voicemail message class. For example, the message class for Interactive Intelligence is IPM.Note.i3Vox.

Resolution v1: So maybe it isn't just voicemails, may you want other message classes converted to work items. Regardless, this can be done using...
  1. PowerShell
  2. Active Directory cmdlets (available with an RSAT installation)
  3. The community developed SMLets for Service Manager (an absolute MUST for anyone wanting to play with SCSM via PowerShell)
  4. OPTIONAL: A virtual/physical machine running Outlook

The fourth step is certainly optional, because you could just as easily install Outlook on one of the Service Manager management servers. But if you have a VM infrastructure I generally avoid putting any additional kind of load on the core SCSM infrastructure. Granted, this is a pretty small trick to execute but to each their own.

Getting Started...
We'll be making use of the following script located here on my TechNet page. This script runs as your SCSM Workflow account via Task Scheduler to rip through the locally available Outlook client every 5 minutes to check for a different type of message class (in this case voicemails) and create Work Items in SCSM with the voicemail file as an attached item. If you're looking really close, it may ring a bell with this script from 2011 with just a few modifications. Since this script is scrubbing for a different type of message class you'll never jeopardize your primary SCSM functions!

You'll also need to configure Outlook to allow programmatic access to itself. Out of the box this is turned off (for obvious reasons of security) but in this case you'll need to either disable it entirely or scope access to it. Once you're done with this you'll also need to create a folder on the machine where this is running (then again, you could easily use a network share if you prefer - just modify the script to point to the new location) so you can temporarily save off the voicemail attachments. I say temporarily as once the Work Item is created the script also does cleanup and deletes the attachments it pulled from the email. This way you can ensure you don't eventually have this script be the cause of an "Out of Disk Space" error.

The other thing this script does is attempt to identify who left the voicemail. Presumably your phone system may leave voicemails with either the called as the sender, subject, etc. This too can be targeted by programmatic means with PowerShell/Outlook. Once id-ed a quick sanity test validates the caller by passing them into a simple "Get-ADuser" check.

  • Isn't this just a hackneyed version of the Exchange Connector? Yes, it absolutely is!
  • Can't I just do this with Orchestrator? You could try, until you realize much like the Exchange Connector within SCSM that the Integration Packs for Exchange in SCO also fundamentally make use of the IPM.Note class.
  • Why can't you just make a management pack for SCSM to allow some of this customization via a Settings pane or something? Hrrmmm. Good point...


Post a Comment