Lync Client, PowerShell, Scripting
comments 5

Scripting Lync 2010 Client in PowerShell

Off late, I have been working on the Lync 2010 client SDK to understand how I can automate some tasks such as updating my Lync status or auto-answer Lync calls or IM conversations when I am away from my computer or in a meeting, etc. This is just the beginning of the list. There are several other tasks I have automated and I will eventually post here.

Here is the link to download Lync 2010 SDK: http://www.microsoft.com/en-us/download/details.aspx?id=18898

Also, make a note of the requirements to install Lync SDK:

    • Visual Studio 2008 SP1 or Visual Studio 2010 RTM for Microsoft Windows Forms or WPF development.
    • Visual Studio 2010 RTM for Silverlight development.
    • Microsoft .NET Framework 3.5 or later service pack.
    • Microsoft Silverlight 4.0 runtime, installed with Lync 2010.
    • Microsoft Silverlight 4 Tools for Visual Studio 2010.
If you don’t want to install Lync 2010 SDK (it comes with a lot of unnecessary baggage), you can just copy the model DLL at “C:\Program Files (x86)\Microsoft Lync\SDK\Assemblies\Desktop\Microsoft.Lync.Model.Dll” from a machine that has Lync SDK installed. This should be sufficient for the task outlined in this post.

For now, I will start with a basic overview of the Lync scripting model and then show a simple example of changing the Lync client status using PowerShell.

There are two Lync development models as described in Lync 2010 SDK documentation:

  • Lync 2010 Controls provides features such as search, presence, instant messaging (IM) calls, and voice calls, which can be integrated into custom applications.
  • Lync 2010 API provides the programming interfaces to develop Lync 2010 applications.

In the context of this post and all other future posts in this topic, I shall talk only about the Lync 2010 API and not the controls.

In the context of Lync 2010 API, there are two development scenarios:

  • Lync 2010 Model API can be used to replicate Microsoft Lync 2010 features in an application while suppressing the Lync 2010 user interface.
  • Lync 2010 Extensibility API can be extend an existing application by integrating a new Microsoft Lync 2010 conversation window in the application.

In the Lync 2010 model API — in UI suppression mode — several Lync 2010 features are not available. This is where the extensiblity API can be used effectively.

So, that is a 30000 ft. overview of Lync 2010 SDK. Let us see example on using Lync 2010 API to change the status of the Lync 2010 client.

The above example is self-explanatory. The first step loads the model API and the subsequent steps load the client object and perform status updates. Stay tuned for more.

Filed under: Lync Client, PowerShell, Scripting

by

Ravikanth is a principal engineer and the lead architect for Microsoft and VMware virtualized and hybrid cloud solutions within the Infrastructure Solutions Group at Dell EMC. He is a multi-year recipient of Microsoft Most Valuable Professional (MVP) award in Windows PowerShell (CDM) and Microsoft Azure. Ravikanth is the author of Windows PowerShell Desired State Configuration Revealed (Apress) and leads Bangalore PowerShell and Bangalore IT Pro user groups. He can be seen speaking regularly at local user group events and conferences in India and abroad.

  • Pingback: Auto answering incoming calls in Lync using PowerShell — Ravikanth Chaganti()

  • Michael Felkins

    This is good stuff, thank you. My idea is to be able to set up a new user with a list of contacts in a particular group. I found a script that will start the add contact wizard, but it only adds one contact at a time and the user has to select the group to put them in. Here is the script to add a contact:

    $assemblyPath = “C:Program Files (x86)Microsoft LyncSDKAssembliesDesktopMicrosoft.Lync.Model.DLL”
    # Import the assembly into the PowerShell session
    Import-module $assemblyPath
    # Get Lync 2010 Extensibility API
    $auto = [Microsoft.Lync.Model.LyncClient]::GetAutomation()
    $item = “user@mymail.com”
    $auto.LaunchAddContactWizard($item)

    I would like to be able to add a list of users and place them in a group.

    $auto = [Microsoft.Lync.Model.LyncClient]::GetAutomation()
    $collection = gc C:ScriptsPS1ContactsEmail.txt
    ForEach($item in $Collection) {
    1. add user
    2. move user to group
    }

  • David Heinrich

    Nice work!
    Maybe you know of a script that I could automate the dialin to a meeting line.
    I do this 8 to 14 times a day and really need something that would do this
    It’s format is +5555551212 then pause 2 sec then DTFM conf code

    any help?

  • Hi Dave, I haven’t got to this yet. Lot of backlog on the comments as I have not been very active in last few months. I will post something on this very soon.

  • David Riu

    Can you use script to auto join to a Lync online meeting?