There might come a time when Lync contacts are lost when you move a Lync user from one pool to another pool. This has happened to me. If you regularly back up Lync contacts, you can easily restore the missing contacts. I'll walk you through how to back up and restore Lync contacts using Windows PowerShell commands in the Lync Server 2013 Management Shell. The areas I'll address are:
- Exporting Lync contacts for a specific user or pool
- Importing Lync contacts for a specific user or pool
Exploring export files
Exporting Lync Contacts for a Specific User or Pool
You can back up the Lync contacts for an entire pool or a particular person. The Lync command you need to use depends on what you're trying to accomplish. For example, here's a command that backs up the contacts for an entire pool:
Export-CsUserData -PoolFQDN "Lon-pool.adatum.com" -FileName "C:\exportedcontacts\Test.zip"
Let's break down this command. Export-CsUserData is the cmdlet you use if you want to export user data for a Lync pool. You use the -PoolFQDN parameter to specify the target pool, which in this case is Lon-pool.adatum.com. Export-CsUserData will create a .zip file that contains the exported user data. You use the -FileName parameter to specify the location where you want that file to reside.
If you want to back up the Lync contacts for a single user rather than the entire pool, you can use a command such as:
Export-CsUserData -PoolFQDN "Lon-pool.adatum.com" -UserFilter "[email protected]" -FileName "C:\exportedcontacts\Test.zip"
Notice the addition of the -UserFilter parameter. You need to include this parameter to grab the Lync contacts for the specified person, which in this case is "[email protected]". As this example shows, you specify the user's Session Initiation Protocol (SIP) address without the sip: prefix and enclose the SIP address in quotes. After the command successfully runs, you'll see the export file in the location you specified, as Figure 1 shows. This file will contain a pair of XML documents, which I'll discuss later.
Importing Lync Contacts for a Specific User or Pool
Once you export your Lync contacts for the entire pool, you have the means to restore them if a user's contact list is accidentally deleted during a move operation. You can use the Update-CsUserData cmdlet to restore Lync contacts. For example, the following command restores the contacts for Adam:
Update-CsUserData -Filename "C:\ExportedContacts\test.zip" -UserFilter [email protected]
When you run the Update-CsUserData cmdlet, you'll receive a prompt asking you to confirm that you want to perform this action, as Figure 2 shows. Lync Server provides this confirmation prompt because you're about to write over the user's existing Lync contacts. In this case, Adam doesn't have any contacts after being moved over to another pool.
After you confirm that you want to perform this action and the command successfully completes, Adam will have to log off, then log back on to his Lync client to see all of his restored Lync contacts. In the event that Adam was only missing a few contacts, those missing contacts would be restored and his present contacts would remain intact. However, Adam would still need to log out, then log back on to the Lync client.
Exploring Export Files
There might be times when you need to search the XML files that are created during the export to validate that certain contacts are present for a particular user. The criterion you need to use to search the XML files isn't exactly intuitive. What you're going to want to search for once you open an XML file is the user's SIP address, but instead of using the sip: prefix, you use the prefix urn:lcd:. For example, to search for Adam's contact list, you'd search for urn:lcd:[email protected]. As Figure 3 shows, by searching on this criterion, you'll jump right to the information for that user.
In Figure 3, you can see several items that are pertinent to Adam. In the Contact Groups section, notice that Adam added Alex to his Buddy list. In addition, at the moment the export was performed, Adam was subscribing to Alex's presence. When a Lync user's contact list has a lot more contacts, you'll see several people that the user has subscribed to and are listed as "Buddy," which signifies that they're in the user's contact list.
Lost and Found Contacts
Having a user's contact list accidently stripped away while movin g a user from one pool to another pool occurs occasionally, but it doesn't have to be an "Oh no, what do I do now?" situation. Keeping Lync contacts backed up through an automated process is a good idea because you'll have the Lync contacts for your entire pool stored in a location that can easily be accessed if a restore is needed.