Powershell Lync Export & Import Script for Users Contacts... for DR?

So if you want to export and import the contact information between to pools for DR here is 2 simple powershell scripts that will help.

This will also move the users from the primary to the backup pool so the backup pool becomes their primary register

you could include this as a larger DR script to backup the rtc database and voice routing etc...

Import Script

 

#Configure these Variables to your environment
###########################################################
$importpath = "c:\share\"
$primarylync = "lync-01.corp.contoso.com"
$backuplync = "lync-02.corp.contoso.com"
###########################################################

Import-module Lync
get-CSUSER -Filter {RegistrarPool -eq $primarylync} |Move-CSUser -Target $backuplync

$dbimport = "C:\Program Files\Common Files\Microsoft Lync Server 2010\Support\dbimpexp.exe"
$xml = $exportpath + "AllUserscontact.xml"
& "$dbimport" /import /HRXMLfile:$xml /restype:user

 

 

Export Script

 

#Configure these Variables to your environment
###########################################################
$backuplync = "\\lync-02\share"
$dbimport = "C:\Program Files\Common Files\Microsoft Lync Server 2010\Support\dbimpexp.exe"
###########################################################
$exportpath = "c:\share\"
$xml = $exportpath + "AllUserscontact.xml"
& "$dbimport" /HRXMLfile:$xml

copy $xml $backuplync