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 [email protected] 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?
Only workaround I have found is to create a conversation with the target user like this:
Import-Module "Microsoft.Lync.Model.dll"
$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