Force update Skype For Business Clients Global Address List

When things don't look right, force them to be right!

null

If you ever had a situation where it would be nice to have your clients Skype for Business Global Address List (GAL) forcefully updated - Then you are likely to have to script it (like I was)!

But keep in mind, the required permissions needed to add a key to the registry.

If you need non-admin users to run this, you will need to create a GPO that sets the required permissions in the registry. This guide will not cover this, but you can read this easy to follow guide on the subject:

[Open Geekshangout.com in new tab]

Or look at the alternative solution after the script…

The script that will force the Skype for Business client to reload the Global Address List

[Link to my GIST of this script on GitHub]

<#
.SYNOPSIS
Script to force update Skype for Business Clients Global Address List
Written by Michael Mardahl (iphase.dk)
(Provided AS-IS, I will not be held liable for any negative impact on anything)

.DESCRIPTION
This script will shutdown the SfB client, update the registry and delete the GAL DB, then start the client again.
It should be run in the users context as it does user specific things.

.EXAMPLE
Just run the script without parameters

.NOTES
The user will need to have access to write to the registry key specified in this script.
#>

Write-Output "Stopping SfB client"
Get-Process -ProcessName lync | Stop-Process

Write-Output "Identifying Office version (2013 or 2016)"
switch (Test-Path "$($env:userprofile)\AppData\Local\Microsoft\Office\16.0")
{
    $true {$ver = "16"}
    $false {$ver = "15"}
}

Write-Output "Adding required key to registry"
reg add HKLM\Software\Policies\Microsoft\Office$ver.0\Lync /v GalDownloadInitialDelay /t REG_DWORD /d 0 /f

Write-Output "Deleting SfB Client GAL db files"

#Remember to change the sipdomain.com text on these two lines, they should be your real domain (if in doubt, just look in that folder on your own client and see).#You could also script a solution that fetches the users SIP address directly from Active Directory. I choose the easy way here...

Remove-Item "$($env:userprofile)\AppData\Local\Microsoft\Office$ver.0\Lync\sip$($env:username)@sipdomain.com\GalContacts.db" -force 
Remove-Item "$($env:userprofile)\AppData\Local\Microsoft\Office$ver.0\Lync\sip$($env:username)@sipdomain.com\GalContacts.db.idx" -force

Write-Output "Starting SfB client again"
Start "C:\Program Files (x86)\Microsoft Office\root\Office$ver\lync.exe"

Permission issue “work around”

Another workaround to the permissions issue, is to elevate permissions temporarily for the registry change to happen. This can be done with a “sudo” like function, replacing the “reg add” line in the above script with this piece of code instead:

function sudo
{
    $file, [string]$arguments = $args;
    $psi = new-object System.Diagnostics.ProcessStartInfo $file;
    $psi.Arguments = $arguments;
    $psi.Verb = "runas";
    $psi.WorkingDirectory = get-location;
    [System.Diagnostics.Process]::Start($psi);
}

sudo "reg" "add HKLM\Software\Policies\Microsoft\Office$ver.0\Lync /v GalDownloadInitialDelay /t REG_DWORD /d 0 /f"

That’s it! - Let me know what you think in the comments section, and feel free to suggest improvements.

Michael Mardahl

Cloud Enabler - Microsoft Certified Professional

Ballerup, Denmark https://www.iphase.dk