Search code examples
powershellazure-active-directoryskype-for-business

Get user's skype status with skype online connector on powershell


I'm working on a little script that outputs the current Skype for Business Status of a user.

Available, Busy, Do Not Disturb. etc.

I already experimented a bit and can output a lot of information. The Script works fine but I can't find a status entry.

This is my code so far:

$userCredential = Get-Credential
$sfbSession = New-CsOnlineSession -Credential $userCredential

Import-Module SkypeOnlineConnector
Import-PSSession $sfbSession #connection opens

Get-CsOnlineUser -Identity "[email protected]"

$currentSession = Get-PSSession
Remove-PSSession -Session $currentSession #connection closes

Am I searching on the wrong spot?

If there is any more information I should provide please ask, I hope we can solve this.


Solution

  • For everyone wondering, I solved this problem. Instead of using the Skype Online Connector, I use the Skype Lync 2013 SDK.

    With this simple code, I can achieve what I wanted.

    $client = [Microsoft.Lync.Model.LyncClient]::GetClient()
    $contact = $client.ContactManager.GetContactByUri("[email protected]")
    $availabilityId = $contact.GetContactInformation("Availability")
    $activity = $contact.GetContactInformation("Activity")
    Write-Output ([Microsoft.Lync.Model.ContactAvailability]$availabilityId)
    

    Note that this in this example, there is no need to enter any credentials, because GetClient() already gets the credentials of your open Skype for Business Service.