Mucking with MWI – Part I

In the process of migrating a customer to Lync recently we inherited an obligation to provide a *BIG* Message Waiting Indicator (MWI) light when-ever a voicemail message arrived in a particular high-priority mailbox.

We figured there were a number of ways we could do this:

  • Optically couple to the MWI LED on an LPE or 3PIP phone. This obvious (albeit a bit clunky) solution was dismissed following our inability to find a commercial sensor and solid state relay or similar combo that could do this. (We didn’t want to be supplying or supporting a home-brew solution)
  • Electrically couple to the MWI LED on an LPE or 3PIP phone. This would obviously void the phone’s warranty and was dismissed due to similar shortcomings as above re home-brew & supportability
  • Perhaps we could get one of the programmable I/O pins in the Snom PA1 to go high on MWI? Alas, nope, not in the current firmware anyway
  • Some custom EWS application? (None were found to exist, and the budget didn’t extend to creating one)
  • Use Exchange’s MWI messages? (Possibly do-able. Tested but ended up somewhere between too messy and too hard).

And thus it was that I embarked on a bit of a campaign to see how many ways I could bring an external MWI light to reality.

Mucking with MWI – Part I is this post. It uses a scheduled PowerShell script to query MWI and light a Blynclight.
Mucking with MWI – Part II opto-couples to the MWI LED in a CX600 to drive a mains-powered light.


Mucking with MWI – Part I

“Are we there yet?”

Let me state right off the bat that I realise this solution isn’t ideal.

Scheduling a script that runs every minute or so, querying Exchange Web Services for your Inbox contents is a bit like having someone in the car on a permanent loop doing the “Are we there yet?” routine in your ear. You’ll be able to get away with it for a handful of users, but there has to be a point at which (1) EWS is going to buckle or throttle you, (2) the management of this sends you barking mad, or (3) you wake up and decide there has to be a better way.

But in the meantime, when you have that ONE noisy user who needs a solution, I have it here for you.

A Video Demo

Check me out in this quick 1:20 video demo on YouTube.

PowerShell script

It’s really quite simple. The script simply queries EWS for new, “unread” voicemail messages in a user’s mailbox, and if there are any it sends a command to the Blynclight to light, flash, change colour, etc. Should the script return no unread voicemails, it sends a similar command to extinguish the light or set it green.

Run without any command-line attributes it defaults to the credentials (and mailbox) of the signed-in Windows user. It first pulls the user’s login name, then queries AD for the e-mail address.

If you provide an “-identity” that contains an “@” the script assumes that’s their e-mail address – without one and it assumes you’ve provided either their SamAccountName or DisplayName and goes on a bit of a fishing expedition in AD looking for an e-mail address.

if ($identity -eq "")
$searcher = [adsisearcher]"(samaccountname=$env:USERNAME)" 
$mail = $searcher.FindOne().Properties.mail
if ($identity -match "@")
#We'll assume it's an e-mail address!
write-verbose "Seemingly valid e-mail address passed"
$mail = $identity
#We'll try our luck in AD:
$AttributeList = @("samaccountname","displayname")
foreach ($Attribute in $AttributeList)
$searcher = [adsisearcher]"($Attribute=$identity)" 
$mail = $searcher.FindOne().Properties.mail
if ($mail -ne $null)
write-verbose "Found a mail address ($($mail)) against $($Attribute)"

Querying another user’s mailbox

You’re also able to pass a different user’s details to query their account instead. Obviously you’ll need to have their credentials in order to query EWS on their behalf, and rather than hard-coding their password into the script, a prep step will be to convert the user’s credentials into a secure string and save them to a file. Rob Costello covers that process off nicely in this post from 2008, and I’ve catered for reading an encoded password in the script.


Blynclight “BlyncCommander”

The other essential piece to this is the new “BlyncCommander” utility from the people behind – as you might expect – the Blynclight(*). I reviewed the Blynclight and its competitor the Busylight a few years back.

There are two software components to this:

  • BlyncCommandServer is an app that lives in the tray and maintains a connection to your Blynclight. If you’ve been around for a while you might consider this a “TSR
  • BlyncCommander is the executable you call with the appropriate command-line parameters and the magic happens. If you have one of the new v3.0 Blynclights you can specify settings for brightness, tone and volume, otherwise your options remain only colour and flash rate.


I said this isn’t ideal, right?

  1. You need a machine to run this on. It’s ideally perhaps something small like a Gigabyte BRIX or an old PC you’ve been using as a doorstop. (You don’t want to run it on the user’s PC because the PS window popping up as the schedule fires will annoy them no end. This was something I wasn’t able to suppress)
  2. Plug your Blynclight in and wait for the driver to install. If this machine doesn’t have internet access, download the driver directly from here
  3. Download the BlyncCommander. (You’ll need to register before you’ll be able to download the ZIP)
  4. “BlyncCommandServer” needs to run when-ever the machine is started or the user logs in. Just add a shortcut to this in the Startup folder. A quick way to get here is to click the Start button and then type “shell:startup” in the search window:Shell-StartupTRAP#1: BlyncCommandServer will crash on launch if its companion “Blynclight.dll” isn’t in the same folder with it. All going well you will now have a little Blynclight icon in your system tray
  5. Confirm the Blynclight’s working before we add any more complexity:
    blynccommander -light red -flash high
    blynccommander -light off
  6. Download the Microsoft Exchange Web Services Managed API 2.2 (“EwsManagedApi.msi”) and run it. The script assumes you’ve accepted the default installation path and that the required DLL is in “C:\Program Files\Microsoft\Exchange\Web Services\2.2\”. It’ll throw an error to tell you if it can’t find it

    TRAP#2: The MSI *won’t run* on an x86 machine, but the DLL within is fine on both x86 & x64, so you’ll first need to run the MSI on an x64 machine then copy the DLL across

  7. Now run the script manually. With no extra parameters it will query the signed-in user’s mailbox. Leave yourself a NEW voicemail – it won’t fall for you marking an old one as Unread – and re-run the script to ensure the light lights. Don’t be too hasty – in my Lab there’s sometimes a lag of 5 – 20 seconds between the message arriving in your Inbox and EWS reporting its presence.
  8. Assuming it’s all working at this point, create a new Schedule. Feel free to use my meeting warmup script as a basis for this if you want to automate it. I’ve highlighted some of the critical settings:
    ScheduledTask-General-editSet the task to “On A Schedule” and set it to “One Time” with a date of “now”.

    The “Repeat task every” list box offers values of 5 minutes through an hour – but if you want something as frequent as every minute you can just type that in over the top! (It’s actually a combo box!)


    For my action I have these values:

    -noprofile -windowstyle hidden -file "C:\Users\me\Downloads\BlyncCommander_v1.0\Get-UnreadVoicemailMessages.ps1"

    (The Hidden WindowStyle didn’t stop it popping up).


    Checking “Run task as soon as possible after a scheduled start is missed” is how we make sure this once-off Task runs repeatedly, even after a reboot:


  9. Now leave yourself some voicemail messages and see what it looks like!



I initially had a few problems with the script driving the light when it was running scheduled – issues with the way I was calling the EXE as it turned out – so I added a “try”/“catch” pairing around the bit calling the BlyncCommander. If there are any issues at this point it will dump the contents of the error to a text file. If that file exists it will hopefully be pointing you to the fix.

“-verbose” will give you some more on-screen output.


Click Get-UnreadVoicemailMessages.ps1 to view the script in your browser, or to download it as a .zip file:

Revision History

April 1st 2015: This is the initial release.


– G.

(*) I used to work for the company behind the Blynclight, but that was many years ago when they used to have a show…

Leave a Reply

Your email address will not be published. Required fields are marked *

... and please just confirm for me that you're not a bot first: Time limit is exhausted. Please reload the CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.