Skip to content

Instantly share code, notes, and snippets.

@inammathe
Created May 18, 2021 00:13
Show Gist options
  • Save inammathe/9a908f86e235afdf3be45456bf76b8a0 to your computer and use it in GitHub Desktop.
Save inammathe/9a908f86e235afdf3be45456bf76b8a0 to your computer and use it in GitHub Desktop.
Set-SkypeAvailability
$LyncSDKLocation = 'C:\LyncSDK\LyncSDK\Assemblies\Desktop'
import-module "$LyncSDKLocation\Microsoft.Lync.Utilities.dll"
import-module "$LyncSDKLocation\Microsoft.Lync.Controls.dll"
import-module "$LyncSDKLocation\Microsoft.Lync.Model.dll"
<#
SDK - https://www.microsoft.com/en-us/download/confirmation.aspx?id=36824
Extract msi out of the exe and run that to get the required assemblies
Microsoft.Lync.Utilities.dll
Microsoft.Lync.Controls.dll
Microsoft.Lync.Model.dll
#>
# Obtain the entry point to the Lync.Model API
$client = [Microsoft.Lync.Model.LyncClient]::GetClient()
$self = $client.Self;
#Set Details of Personal Note and Availability
#Useful availability codes for use below
# 3500 Available,
# 15500 Away (converted to "Off Work" in this script by setting activity ID),
# 6500 Busy,
# 9500 Do not disturb,
# 12000 Be Right Back
# Example - flicking through a few availability types each second
$availabilitys = @(9500, 3500, 15500)
while ($true)
{
foreach ($availability in $availabilitys)
{
# set presence availability of the local user
$contactInfo = new-object 'System.Collections.Generic.Dictionary[Microsoft.Lync.Model.PublishableContactInformationType, object]'
$contactInfo.Add([Microsoft.Lync.Model.PublishableContactInformationType]::Availability, $availability)
If ($availability -eq 15500)
{
$contactInfo.Add([Microsoft.Lync.Model.PublishableContactInformationType]::ActivityId, "off-work")
}
# publish availability change
$publishAction = $self.BeginPublishContactInformation($contactInfo, $null, $null)
$self.EndPublishContactInformation($publishAction)
sleep(1)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment