#DLL Requirements: https://www.microsoft.com/en-us/download/details.aspx?id=36824 - Lync SDK
function SetSFBStatus
{
import-module "C:\LyncScript\lib\Microsoft.Lync.Controls.Dll"
import-module "C:\LyncScript\lib\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)
$availability = 12000
$date = [DateTime]::Now
#$message = "Availability script last run $date"
#Publish personal note and presence availability of the local user
$contactInfo = new-object 'System.Collections.Generic.Dictionary[Microsoft.Lync.Model.PublishableContactInformationType, object]'
$contactInfo.Add([Microsoft.Lync.Model.PublishableContactInformationType]::PersonalNote,
$message)
$contactInfo.Add([Microsoft.Lync.Model.PublishableContactInformationType]::Availability,
$availability)
If ($availability -eq 15500) {$contactInfo.Add([Microsoft.Lync.Model.PublishableContactInformationType]::ActivityId, "off-work")}
$ar = $self.BeginPublishContactInformation($contactInfo, $null, $null)
$self.EndPublishContactInformation($ar)
}
while($true)
{
Start-Sleep -Seconds 30
SetSFBStatus
}