Lync UCS Contacts Reporting with Powershell

By default a Lync enabled account within a Lync/Exchange 2013 environment will be enabled for UCS (Unified Contact Store). This means that the Lync contacts get saved in the Lync user’s mailbox and not the Lync database. In order to get a list of the contacts associated with these accounts you have to export data to a zip file with some debug Lync commands and, even then, the information is buried in a hard to interpret XML file.

I had a need to validate the contacts which were getting stored in UCS for Lync users and so I came up with this script to accomplish the task. It creates a temporary directory and exports all the passed Lync users’ UCS contact information in a zip file within the directory. The function then parses and returns psobjects with the contact information by reading in the xml file directly from the zip file (no extraction to disk). After returning contact information back as nicely formatted powershell objects the temporary files are all cleaned up.

Here are a few small examples of what can be done:

You can download this script at the Microsoft Technet Gallery or at my new Github repo.

Comments (7)

  1. 9:47 AM, 11/26/2014davidchr  / Reply

    I can run the script now but I had to comment out the following line of code
    function Get-LyncUCSContacts { and the closing } at the end of the script. Nowhere in the script did I see Get-LyncUCSContacts used to call the function.

    • 1:56 PM, 11/26/2014Zachary Loeber  / Reply

      Hello,

      If you had to do that then you didn’t dot source the script properly. What you did essentially turns the entire script into a function. That works as well so glad you worked around the issue. I’d take a quick look at some articles on dot sourcing to understand the difference when time permits though (http://ss64.com/ps/source.html).

      Cheers

  2. 9:38 AM, 11/26/2014davidchr  / Reply

    I am running it on a Lync 2013 front end server. I am also dot-sourcing the file. Sorry if I didnt make that clear above.

  3. 11:25 AM, 11/25/2014davidchr  / Reply

    Hi Zachary…I havent had any success getting your script to produce any output. I dont see any errors either. Ive tried running this cmdlet against my userID that has successfully been migrated to UCS on Exchange 2013. Any suggestions?

    • 12:33 PM, 11/25/2014Zachary Loeber  / Reply

      Does dot sourcing the script and running the function with -verbose produce anything?

      • 1:54 PM, 11/25/2014davidchr  / Reply

        I tried -verbose but I didnt even get verbose output. (seems to me like the verbose switch is not working as expected. I noticed some of your write-verbose code and added a duplicate write-host and Im not even seeing anything in LMS). LMS will only let me run the script with dot sourcing otherwise I get an error.

        • 8:33 PM, 11/25/2014Zachary Loeber  / Reply

          Make certain that the function is run on a Lync server and that you have dot sourced the file (. .\scriptname.ps1)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Pingbacks (0)

› No pingbacks yet.

Follow

Get every new post delivered to your Inbox

Join other followers