Detecting Skype Activity with PowerShell

Share on:

I'm working on a project to get a number of drivers updated across an environment. One of the biggest problems is that if we update certain audio, video, or network drivers while the user is in a Skype call, the call will fail. Often in testing I found that reconnecting to the Skype call or presentation was difficult or impossible and they were left as a "ghost participant" in the meeting without actually being there. To avoid this problem, I started work on a short script to detect activity before the installation began.

 1Add-Type -Path "<PathToDLL>\Microsoft.Lync.Model.dll"
 3$skypeIsBusy = @(
 4    "in-a-conference",
 5    "on-the-phone",
 6    "in-a-meeting",
 7    "in-presentation"
10$skypeClient = [Microsoft.Lync.Model.LyncClient]::GetClient()
12$mySIP = $skypeClient.self.Contact.Uri
13$mySIP = $mySIP.SubString($mySIP.IndexOf(":")+1)
15$myContact = $skypeClient.ContactManager.GetContactByUri($mySIP)
17$activityId = $myContact.GetContactInformation("ActivityId")
19Write-Host $activityId
21If($activityId -in $skypeIsBusy) {
22    Write-Host "Skype is Busy.  Abort Mission!"
23    Exit 99
26Write-Host "Looking good!"

Some notes about the script:

  • You'll need the LyncSDK. Specifically, just the single DLL, and it doesn't need to be installed on the target systems, it just needs to be there somewhere.
  • You'll need to update the path in line #1 of the code to reference where you're keeping the DLL.
  • If a user manually changes to "Away" while on a call, the activity ID will change to away and this script will not detect they are on a call.

I'd like to thank leedesmond's blog which got me most of the way there, and also make reference to this MSDN page which lists the ActivityId's.

No comments