23 September 2016

Backup local user contacts from Lync 2013 and Skype for Business 2015 with Powershell

After migrating from Lync 2010 to Skype for Business 2015 the moment came to move all the users to the new registrar pool and all the local user contacts went missing.

To avoid this from happening to you, here's what you can do.

Copy the text below into a new text file and name it "Skype4BusinessUserContactsBackup.ps1"
$fileName = (Get-Date -Format ddMMyyyy) + "-SkypeUsersContactsBackup.zip"
$Path = "\\Domain.lan\Some\path\to\some\where"
# Set limit for older than days
$limit = (Get-Date).AddDays(-365)
# Delete files older than the $limit.
Get-ChildItem -Path $path -Recurse -Force | Where-Object { !$_.PSIsContainer -and $_.CreationTime -lt $limit } | Remove-Item -Force
#(Join-Path $Path $filename)
Export-CsUserData -PoolFqdn Yourpoolname -FileName (Join-Path $Path $filename)
Short description of what this all does:
$filename, set a filename in current date and time format and add SkypeUsersContactsBackup.zip.
File name looks like this: 23092016-SkypeUsersContactsBackup.zip.
$path, specify a path where the file will be saved.
$limit, how many days before we start deleting the backup zip files.
At the end the export from the pool will be written in the destination made from $path and $filename.

Then create a scheduled task with these action settings:

Program/script: Powershell.exe -command ". 'path to your script\scriptname.ps1'"
Set it to run at a monthly schedule or more as you desire.
The file in my environment is about 16MB for roughly 1600 users.

Now when the time comes to restore some contacts for a user, several or all users, you'll need this GUI script from Anthony Caragol.
http://www.skypeadmin.com/2014/07/14/new-tool-lync-2013-backup-and-restore-tool-gui/
Download from here:
http://gallery.technet.microsoft.com/Lync-2013-Backup-and-1f3167c8
It still works on Skype for Business.

No comments:

Post a Comment