Lync Client, PowerShell, Scripting
Leave a comment

Finding Lync contact capabilities using PowerShell

I wrote my last post on Finding Lync contact availability using PowerShell exactly a month ago! Life has been busy. I had my Masters exams and then lot of backlog at work!

Well, I am back and it feels good to be writing again.

As a continuation to the Lync series of posts, I will show you how to find the Lync conact capabilities using PowerShell. This is especially important when we want to automatically invoke a voice call or a video chat with a Lync contact. The method for this is very similar to finding the Lync contact availability.

If you don’t have Lync SDK installed (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 today’s post, we will once again look at the ContactManager class. As usual, let us first get the Lync Model namespace loaded.

Once we have the $client instance, we can use the GetContactByUri method in ContactManager class to create a new contact object. The argument to this method can be an email address or SIP uri or a phone number.

After the above step, we can use the GetContactInformation method on the $contact object to retrieve the contact capabilities. This method takes an enumeration value of type contactInformationType.

This method returns an integer which belongs to the ContactCapabilities enumeration. However, this is an integer. So, we need to find the actual string equivalent of this enumeration. The simple way to do this is to cast the value returned by GetContactInformation() method to the Lync type

This is how we do it:

You can parse the output to find if the capability you need exists or not.

Also, before knowing the contact capabilities, you may also want to find the capabilities of the local Lync client. This is quite easy. We already have an instance of local Lync client in $client. We can use the Capabilities method of the $client object to find the client capabilities.  This returns an integer value of the type LyncClientCapabilityTypes.

Hope you found this helpful. In the next post, I will show you how to respond automatically to an incoming IM conversation.

Filed under: Lync Client, PowerShell, Scripting


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.