Monday, October 20, 2014

Exporting and Importing Lync Contacts for a User

Exporting Contacts:

To make your user's experience more seamless when moving pools or if, for some reason the user's account has to be deleted and re-created, the following procedure will allow you to export his/her contacts and then import them into the new account.

In Lync 2010:

To export a user’s contact list, we’re going to use a Lync utility called “dbimpexp.exe”. This utility is included in the Resource Kit, so obviously, that must be installed before you can access the utility. Open a command prompt and type, “cd C:\Program Files\Common Files\Microsoft Lync Server 2010\Support”. Once you’re in the support directory, type:

dbimpexp.exe /user:<sipaddress> /sqlserver:domain-LYNCSQL1.domain.com\lync /hrxmlfile:E:\contacts\userfirst_last_contacts.xml

Your display will look like:

C:\Program Files\Common Files\Microsoft Lync Server 2010\Support>dbimpexp.exe /user:first.last@domain.com /sqlserver:domain-LYNCSQL1.domain.com\lync /hrxmlfile:E:\contacts\userfirst_last_contacts.xml
SQL Schema Version: 59
User Data Schema Version : 21
Exporting 1 Homed Resource(s) from database...
100% complete.
Export completed successfully.

You have now exported the user’s contact list.

In Lync 2013:

This functionality has been incorporated into Lync PowerShell. You simply use the following code:

Export-CsUserData -PoolFqdn "pool.domain.com" -FileName "e:\Contacts\First_Last_ExportedUserData.zip" -UserFilter first.last@domain.com

Importing Contacts:

In Lync 2010:

You can restore the contact list now using the process below:

From a command prompt in the C:\Program Files\Common Files\Microsoft Lync Server 2010\Support directory, type:

dbimpexp.exe /import /user:<sip address>/sqlserver:domain-LYNCSQL1.domain.com\lync /hrxmlfile:”<path where the xml file resides>” /restype:user

Your display will look like:

C:\Program Files\Common Files\Microsoft Lync Server 2010\Support>dbimpexp.exe /import /user:first.last@domain.com /sqlserver:domain-LYNCSQL1.domain.com\lync /hrxmlfile:E:\contacts\smcnamaracontacts.xml /restype:user
SQL Schema Version: 59
User Data Schema Version : 21
Importing Homed Resources into database...
1 Resource(s) imported.
Import completed successfully.

In Lync 2013:

This functionality has been incorporated into Lync PowerShell. You simply use the following code:

Import-CsUserData -PoolFqdn "pool.domain.com" -FileName "e:\contacts\First_Last_ExportedUserData.zip" -UserFilter first.last@domain.com

Export from Lync 2010 then Import to Lync 2013:

To import your 2010 contacts into 2013, you must convert the data, as 2013 uses a different format than 2010. Thankfully, there is a 2013 PowerShell cmdlet that does the heavy lifting. To Export a User's Contacts from 2010:

Export from 2010:

To export a user’s contact list, we’re going to use a Lync utility called “dbimpexp.exe”. This utility is included in the Resource Kit, so obviously, that must be installed before you can access the utility. Open a command prompt and type, “cd C:\Program Files\Common Files\Microsoft Lync Server 2010\Support”. Once you’re in the support directory, type:

dbimpexp.exe /user:<sipaddress> /sqlserver:domain-LYNCSQL1.domain.com\lync /hrxmlfile:E:\contacts\userfirst_last_contacts.xml

Your display will look like:

C:\Program Files\Common Files\Microsoft Lync Server 2010\Support>dbimpexp.exe /user:first.last@domain.com /sqlserver:domain-LYNCSQL1.domain.com\lync /hrxmlfile:E:\contacts\userfirst_last_contacts.xml
SQL Schema Version: 59
User Data Schema Version : 21
Exporting 1 Homed Resource(s) from database...
100% complete.
Export completed successfully.

Convert Your Contacts:

Copy the E:\contacts\userfirst_last_contacts.xml file to your 2013 Front End server, then run the following command:

Convert-CsUserData -InputFile "E:\contacts\userfirst_last_contacts.xml" -OutputFile "e:\contacts\First_Last_ExportedUserData.zip" -TargetVersion Current

Import Your Contacts to Lync 2013:

Run the following command to import the converted contact data:
Import-CsUserData -PoolFqdn "pool.domain.com" -FileName "e:\contacts\First_Last_ExportedUserData.zip" -UserFilter first.last@domain.com