Lync Click-to-Call Script

by Jamie Schwinn on February 13, 2014

This post is a follow-up to Richard Brynteson’s post, Controlling Click-to-Call. Richard wrote a great post detailing how to control Lync’s Click-to-Call feature and force it to always call the contact via Lync call. By default, Lync will remember the last number you called a particular contact at and choose that number as the default Click-to-Call target.

After reading Richard’s post, I decided to write a PowerShell script that implements Richard’s Option #1 – Restrict Access to the Key. This only works for Lync 2013, but this script could be easily be modified for Lync 2010 by changing the registry path.

Get-ChildItem -path hkcu:\Software\Microsoft\Office\15.0\Lync | % { `
	if ($_.Name.Contains("@")) { `
        $key = $_.OpenSubKey("ContactStateCacheU", $true)
		if($key) { `
            $regPath = "HKCU:\Software\Microsoft\Office\15.0\Lync\" + ($_.Name.Split("\"))[6] + "\ContactStateCacheU"
            $acl = Get-Acl -Path $regpath
            $acl.SetAccessRuleProtection($true, $true)
            $acl | Set-Acl
            $user = [Environment]::UserDomainName + "\" + [Environment]::UserName
            $type = [System.Security.Principal.NTAccount].UnderlyingSystemType
            $acl.GetAccessRules($true, $true, $type) | % { `
                if($_.IdentityReference -eq $user) { `
                    $acl.RemoveAccessRule($_)
                }
            }
            $acl | Set-Acl
         } `
	} `
}

This script will iterate through all of the Lync identities that have signed into Lync under the current user account and remove Read/Write permissions from the ContactStateCacheU Key for the currently logged on user.

Download the script here

Be Sociable, Share!

{ 1 trackback }

Previous post:

Next post: