A few days ago I searched for a solution to administrate contacts for several Lync 2010 users. Sorry for my english.

I found the great VBS script LyncAddContacts from Jeff on this website: expta.com. Very great tool, I appreciate Jeff’s work. But the fact of the matter that I’m familiar with Powershell, I wonder whether it is possible with Powershell and I can use my well-loved pipeline.

As the original script you have to use the DBIMPEXP utility from the Lync 2010 server to import and export contacts.

I quote the description from expta.com:

The purpose of Add-LyncContacts is to add the same contact groups and contacts to multiple users programmatically.

For example, you may want to import a contact group called “Company Contacts” that contains contacts for everyone in the company.

Here’s how it works:lync

  1. Create a template (source) user in Lync with the contact groups and contacts that you want to export.
  2. Import the powershell module Add-LyncContacts.psm1
  3. Execute the cmdlet “New-CSContactExport” to export the source user’s contacts and groups
  4. Execute the cmdlet “New-CSContactImport” to import the contact/group template to one or more users.

Prerequisites:

  • You have to run the cmdlets on the Lync server from which you will export/import the data.
  • You must be a member of the CSAdministrator security group to run this tool. This group has rights to export and import contact groups and contacts to all users.
  • You must copy the DBIMPEXP.EXE tool from the \Support folder on the Lync Server 2010 installation media to the same folder where you call the Add-LyncContacts-Modul cmdlets.
  • You must have read, write and execute rights to the folder where the Add-LyncContacts-Modul cmdlets will be called, because the script will create temporary files for editing.

Usage:

  • Start Powershell with Administrator rights.
  • Import-Module Add-LyncContacts.psm1
  • Navigate to the folder where you can find the DBIMPEXP.EXE utility
  • If you use Lync Server Enterprise Edition then you have to set the required SQL server parameter

To backup all user data to a specific filename, use the following cmdlet:

New-CSContactBackup -FileName backup.xml

For the Lync Server Enterprise Edition the cmdlet will be executed like this:

New-CSContactBackup -FileName backup.xml -SQLServer sql.domain.com

where backup.xml is the backup filename and sql.domain.com is the SQL server used by the front-end pool.

Once the backup has been performed, you can begin the export/import process. First, you must export the source user’s contact groups and contacts. The following example exports this information from a user named “test” on a Lync Standard Edition server:

New-CSContactExport -SIPName test@lync.local -FileName: testExport.xml

where test@lync.local is the SIP address of the user you want to export and textExport.xml is the exported file. For a Lync Enterprise Edition server use the -SQLServer parameter.

Second, you import the contact groups and contacts to one or more user(s). The following example imports the data to a user named “test” on a Lync Standard Edition server:

New-CSContactImport -SIPName test@lync.local -FileName: testExport.xml

Lync Server Enterprise Edition:

New-CSContactImport -SIPName <a href="mailto:test@lync.local">test@lync.local</a> -FileName: testExport.xml -SQLServer:sql.lync.local

The followings two examples import the same contact groups and contacts to several SIP enabled users:

Example 1: Users from a txt file

Get-Content users.txt | New-CSContactImport -FileName contacts.xml

where the txt file looks like this:

test1@lync.local

test2@lync.local

Example 2: Get users from the ActiveDirectory

Import-Module ActiveDirectory

Get-ADUser -Filter * -Properties msRTCSIP-PrimaryUserAddress | ?{$_."msRTCSIP-PrimaryUserAddress" -ne $null} | Select-Object @{label='SIPName';Expression={$_."msRTCSIP-PrimaryUserAddress"}} | New-CSContactImport -FileName contacts.xml

where contacts.xml is the source template for the contact groups and contacts.

A nice benefit of this tool is that contacts will not get a notification that so-and-so has added them to their contact list. This is really useful in preventing unnecessary pop-ups from the Lync client.

Special thanks go to Jeff from expta.com.

Powershell Module Download: Add-LyncContacts


Wenn dir dieser Artikel gefallen hat, kannst du ihn mit einem Klick auf die folgenden Buttons weiterempfehlen. Möchtest du in Zukunft keine neuen Beiträge mehr verpassen? Dann abonniere doch den RSS Feed dieses Blogs. Vielen Dank!