#skype4b Set Presence Idle Away Threshold with PowerShell

The majority of client-side settings in Skype for Business 2016 client are controlled in-band whereas certain parameters continue to be configured using Group Policy (centrally in an AD environment). The latter essentially writes to the corresponding key/value pair in the Windows registry for each user in HKCU:.

One such popular setting is the Away status. Because both Active Directory Computer and User Group Policy are applied at computer start/user log on, and automatically refreshes every 90 minutes in the background by default (+30 minutes random offset), manual configuration of this setting will be overwritten eventually.

To workaround this constraint …
…, make a call to Set-Skype4bStatusThreshold.ps1 in your PowerShell $profile or set it up to run in a separate process as illustrated:

Start-Process -FilePath ‘powershell.exe’ -ArgumentList “-NoProfile -Command Set-Skype4bStatusThreshold.ps1”

In order for the settings to be active, ending and restarting the skype4b client is essential. Note that IdleThreshold and AwayThreshold do not exist by default and will be created with a first call to SetValue().

################################################################################
# Copyright (c) 201x-2017 leedesmond.com
# All Rights Reserved. Use at your own risk and responsibility.
# Set-Skype4bStatusThreshold.ps1
# Version 1.00
################################################################################
try {
$iap = (Get-ItemProperty “HKCU:\Software\Microsoft\Office\16.0\Lync”); #replace with 15.0 for the 2015 version
“As-is: IdleThreshold $($iap.IdleThreshold), AwayThreshold $($iap.AwayThreshold)”;

if ($iap.IdleThreshold -le 5 -or $iap.AwayThreshold -le 5 -or
$iap.IdleThreshold -eq $null -or $iap.AwayThreshold -eq $null)
{
New-Variable -Name threshold -Value 360 -Option Constant; # minutes (6 hours)
Stop-Process -Name Lync -ea:SilentlyContinue;
Start-Sleep -Seconds 5;

$registry = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey(“CurrentUser”, $env:computer);

$key = $registry.OpenSubKey(“Software\Microsoft\Office\16.0\Lync”, $True);
$key.SetValue(“IdleThreshold”,$threshold,”DWORD”);
$key.SetValue(“AwayThreshold”,$threshold,”DWORD”);

Start-Process -FilePath “C:\Program Files (x86)\Microsoft Office\Office16\lync.exe”;

“After: IdleThreshold $($key.GetValue(“IdleThreshold”,$null)), AwayThreshold $($key.GetValue(“AwayThreshold”,$null))”;
}
} catch
{
“skype4b/lync not started”;
}
################################################################################
 

To go one step further once $threshold does exceed (maximum settable value in the UI), a simple VBScript will prevent Away status from ever kicking into action as long as a user stays log in to the system.

Have fun!

‘ keepalive.vbs
‘ source: How can I set lync 2010 client presence to ignore pc lock?

Dim WshShell
Set WshShell = WScript.CreateObject(“WScript.Shell”)

Do While True
WshShell.SendKeys(“{F15}”)
WScript.Sleep(55000)
Loop

Bookmark the permalink.

Leave a Reply