Is it possible to change status of Microsoft Lync 2010 by script?
I want Script which works on Win XP and change status to available after fixed interval.Tried to search in internet but was not successful in finding one.
For Lync 2013 this PowerShell script works. You'll need to install the Lync 2013 SDK first. The SDK installer might say you need to install Silverlight 4, but don't worry about that, it's not necessary.
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process -Confirm:$false
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser -Confirm:$false
Import-Module "C:\Program Files\Microsoft Office\Office15\LyncSDK\Assemblies\Desktop\Microsoft.Lync.Model.dll"
Import-Module "C:\Program Files\Microsoft Office\Office15\LyncSDK\Assemblies\Desktop\Microsoft.Lync.Controls.dll"
$client = [Microsoft.Lync.Model.LyncClient]::GetClient()
$availability = [Microsoft.Lync.Controls.ContactAvailability]::Away
$contactInfo = (New-Object "System.Collections.Generic.Dictionary[Microsoft.Lync.Model.PublishableContactInformationType,object]") -As "System.Collections.Generic.IEnumerable[System.Collections.Generic.KeyValuePair[Microsoft.Lync.Model.PublishableContactInformationType,object]]"
$contactInfo.Add([Microsoft.Lync.Model.PublishableContactInformationType]::Availability, $availability)
$ar = $client.Self.BeginPublishContactInformation($contactInfo, [System.AsyncCallback]$null, [object]$null)
$client.Self.EndPublishContactInformation($ar)
That sets the status to "Appear Away", but you can change [Microsoft.Lync.Controls.ContactAvailability]::Away
into this [Microsoft.Lync.Controls.ContactAvailability]::None
to reset the status.
According to the documentation, the Lync binary does not offer that feature. However, you could use the Lync SDK to achieve what you want by writing a small helper application (or incorporating the relevant code in your current application).
According to an MVP in the Microsoft forums, this also is not available out-of-the-box.
However, according to the documentation, a PowerShell script like this one should be able to do the trick:
import-module "C:\Program Files (x86)\Microsoft Lync\SDK\Assemblies\Desktop\Microsoft.Lync.Controls.Dll"
$availability = [Microsoft.Lync.Controls.ContactAvailability]::Available
$contactInfo = new-object 'System.Collections.Generic.Dictionary[Microsoft.Lync.Model.PublishableContactInformationType, object]'
$contactInfo.Add([Microsoft.Lync.Model.PublishableContactInformationType]::Availability,
$availability)
$ar = $self.BeginPublishContactInformation($contactInfo, $null, $null)
$self.EndPublishContactInformation($ar)
This script requires the Lync SDK or the Lync SDK redistributable to be installed.
Much of this information has been taken from here.
The above post does not work. More DLL modules are needed. But i've made the following changes below so it works. Then you can use TaskSch to get it to run automatically. Still needs the 2010 Lync SDK installing.
Set 15550 to mean 'Off-Work' not 'Away'. More useful.
See - http://blogs.technet.com/b/heyscriptingguy/archive/2012/08/11/weekend-scripter-use-the-windows-task-scheduler-to-run-a-windows-powershell-script.aspx
Note this code does not check if LYNC is signed in. If it is not it will not run.
import-module "C:\Program Files (x86)\Microsoft Lync\SDK\Assemblies\Desktop\Microsoft.Lync.Controls.Dll"
import-module "C:\Program Files (x86)\Microsoft Lync\SDK\Assemblies\Desktop\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 = 3500
$date = [DateTime]::Now
$message = "Remote Work. UK Time +5 hours EST (US), -5.5 IST (India). 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)
Ok - This is what I did
C:\Program Files (x86)\Microsoft Office\Office15\LyncSDK\Assemblies\Desktop\
for both of those.ps1
script If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With