Get Skype for Business User Status/Availability issue in Powershell

限于喜欢 提交于 2019-11-30 21:13:54

问题


I'm using powershell to get the Status/Availability of certain users by using the following code:

Import-Module "C:\...\Microsoft.Lync.Model.dll"

$Client = [Microsoft.Lync.Model.LyncClient]::GetClient()

$Contact = $Client.ContactManager.GetContactByUri( $args[0] )
Write-Host $Contact.GetContactInformation("Activity")

Let's say I'm passing in testuser@testcompany.com as the script argument.

If I run this script, it will return "Presence unknown". However, if I open up the Skype client manually and search for the user, I can see their availability then (let's say this user is set to Available).

Now, if I run my script again now after I've searched for them in Skype, the script will return the proper result by printing "Available" to the console. The script will continuously return the proper result until I restart Skype. At the point, it will return "Presence unknown" again until I search for the user in Skype.

If the user is in my Recent Conversations in Skype and I simply view my Recent Conversations tab rather than searching for them, that is enough to have the script start returning the proper result.

It would appear as though it is unable to query their availability until it is manually loaded into cache(?) from my client. Any idea why this would possibly happen or how I can have it return the proper results without manually searching for the user first?


回答1:


Looks like you have to subscribe to user presence information. Lync SDK MSDN documentation has outlined the solution at https://msdn.microsoft.com/en-us/library/office/jj937284.aspx.

Similar solution at https://social.msdn.microsoft.com/Forums/en-US/12357db7-769f-4808-bc99-9b2fb2ed8ce2/presence-unknown?forum=communicatorsdk




回答2:


Only workaround I have found is to create a conversation with the target user like this

$client = [Microsoft.Lync.Model.LyncClient]::GetClient()
$contact = $client.ContactManager.GetContactByUri($email)
$convo = $client.ConversationManager.AddConversation()
$convo.AddParticipant($contact) | Out-Null
Write-Host $contact.GetContactInformation("Activity")
$convo.End() | Out-Null

It doesn't appear to cause any IM windows to popup on the users side.

It would be interesting to see your powershell code for the subscription solution



来源:https://stackoverflow.com/questions/43104066/get-skype-for-business-user-status-availability-issue-in-powershell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!