Force update Skype For Business Clients Global Address List

If you ever had a situation where it would be nice to have your clients SfB GAL forcefully updated,
this script could help you!
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:
https://www.puryear-it.com/set-permissions-windows-registry-key-entire-ad-network

Or look at the alternative solution after the script…

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<#
.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 
 
.DESCRIPTION
This script will shutdown the SfB client, update the registry and delete the GAL DBm, 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).
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"

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:

1
2
3
4
5
6
7
8
9
10
11
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"

Leave a Reply

Your email address will not be published. Required fields are marked *