Microsoft Lync has a rich set of .NET APIs which make it easy to extend the platform and integrate it with other applications. This blog helps explain how to use them.

Installing and troubleshooting MSPL scripts

Posted: July 26th, 2011 | Author: | Filed under: Lync Development, MSPL | Tags: , | 3 Comments »

In my last post, I described some of the basics of Microsoft SIP Processing Language, or MSPL, using a simple script as an example. That last post ended with a cliffhanger: how does the MSPL script get installed on the Lync Front End Server?

Today, I’m going to answer that question.

Picking up where we left off, we have an application manifest file called I’ve taken the liberty of saving it to my Front End Server at C:\ Normally, you’d probably want to put it somewhere else, but I’ll leave it there for simplicity.

The next step is to open up Lync Server Management Shell, which you can find at Start -> Microsoft Lync Server 2010 -> Lync Server Management Shell. It’s very likely you’ve used it before, if you’ve done any Lync configuration or created trusted application objects for your UCMA applications. If not, there are some excellent resources at

To start, you can see all the existing server applications by running the Get-CsServerApplication command. Most will have an identity that starts with Service:Registrar, indicating that they are running on the Front End Server. (It’s perfectly possible to have an application running on another server, though, such as the Edge Server.) The priority value indicates the order in which the applications are started and the order in which they get to process requests. Lower values indicate higher priority. So the application with priority 0 will be started first and will handle requests before all of the others get to handle them.

To install our script, we need to use the New-CsServerApplication command. Here’s what we’ll need to enter into PowerShell:

New-CsServerApplication -Identity "Service:Registrar:server.domain/Simple"
   -Uri "" -ScriptName "C:\"
   -Enabled $true -Critical $true

Let’s go through the parameters one by one. The Identity parameter starts with Service:Registrar: to indicate that this script applies to the registrar, a.k.a. Front End Server, followed by the FQDN of the server itself. After this is a slash, followed by the name of the application, which can be whatever you want.

You may remember that in the script, we set a URI for the script in the root element, using the appUri attribute:

<lc:applicationManifest appUri="" xmlns:lc="">

This is the URI you pass in as the Uri parameter. This identifies the application, and if it doesn’t match what you entered in the application manifest, the application will not load.

The ScriptName parameter, which is named a bit confusingly, should contain the path to the .am file.

The Enabled parameter is self-explanatory: if you want your application to run, it should be set to true; otherwise it should be false.

The Critical parameter determines whether Lync Server can start if your application does not start for some reason. Here, it’s set to true, but if your script is not absolutely required, you can set it to false to avoid bringing down the server if your script doesn’t work. You might want to leave it set to true if you’re using your script for something like legal compliance, and it shouldn’t be possible to bypass it even if it’s not functioning.

Once you run this command, the script will be installed. You can rerun Get-CsServerApplication to verify that it is now listed. If you need to change any of the settings, use the Set-CsServerApplication command.

Next, in order for the script to be loaded, we need to restart the Lync services. You can do this through PowerShell using the Stop-CsWindowsService and Start-CsWindowsService commands, or through the Lync Server Control Panel.

Now, because Visual Studio doesn’t check the syntax of the MSPL scripts, it’s not uncommon to have an error in the application manifest file. If this is the case, the application won’t start properly. To check that the application has started, you can take a look at the Lync Server log in the Event Viewer.

If something went wrong, you’ll likely see a message like this:

Generally, you’ll see one or more other error messages in the vicinity that will tell you a bit more about the problem: - missing node

By looking at these messages, you can generally figure out what the problem is, and go back to your .am file to correct it, after which you’ll need to restart the Lync services to try again.

When the application loads successfully, instead of error messages you’ll see a message like this:

At this point, you can try out the application by sending some messages.

I’ve still only scratched the surface of what you can do with MSPL. In future posts, I’ll explain how you can reroute requests to a UCMA application, perform filtering of different kinds, and insert SIP headers or message content.

3 Comments on “Installing and troubleshooting MSPL scripts”

  1. 1 wwe said at 6:25 am on September 26th, 2011:

    I’m trying to develop my own script. I want to do additional logging but as I expect a lot of log entries I want them to go to the logging tool or plain file rather them event log. MSDN say you can use Log(Debug,true,”this is my log message”) but I don’t find where this is going to.
    Logging to Eventlog using Log(Error…) or Log(Warning) works fine…

  2. 2 Michael said at 10:40 am on October 19th, 2011:

    You need to use “Debugr” instead of “Debug”. I have no idea why, but it’s listed that way in the documentation and that’s what works.

  3. 3 Michael said at 10:42 am on October 19th, 2011:

    Also, the way to view the messages is to run the ApiLogger.exe tool while debugging your application. It’s part of the Lync Server 2010 SDK and the default install location is C:\Program Files\Microsoft Lync Server 2010\SDK\Bin\ApiLogger.exe.

Leave a Reply

  • Note: Comment moderation is in use because of excessive spam. Your comment may not appear immediately.