Script: New Lync Users Report

One of many things that my customers asks me, is if there is a way in which they can get a list of all users that were enabled for Lync over the last X amount of days. This request is usually common in organizations where there are different teams for managing the Lync side, one team who manage the Lync infrastructure and another team who manage the user’s enablement and policy assignment.

At first, I thought that Get-CsUser should probably have that information, but unfortunately, it seems that the output of the command Get-CsUser contains two date parameters for the user (if you run it with Get-CsUser | Select-Object *), but those two are not related to the Lync side, but more to the Active Directory side.

  • WhenChanged
  • WhenCreated

What it actually means is that those two parameters does not reflect the enablement or creation date in the Lync system, but rather the creation in Active Directory.
For example, if I had a user in AD who was created two years ago and got enabled for Lync only a week ago, the WhenCreated attribute would still shows his creation date as of two years ago.

With that said, for some companies this information is relevant enough, because usually when a user is created in Active Directory, that the same time when he gets enabled for Lync so the information is pretty accurate.

But, In order to provide a better solution and cover all enablement scenarios, I’ve decided to go over the Lync databases information and structure. Fortunately I found that under the [RTC] database within the [ResourceDirectory] table, there is probably a better solution to the issue I was facing.

Looking into the [ResourceDirectory] table properties, i saw there are two columns headers, the InsertTime and UpdatedTime which contains the data I needed for all of the resources within the Lync environment:

image

The problem on the other hand is that all Users were showing with their SID number and not with their actual DisplayName or SamAccoutName, so I had to add a function to the script to convert all of those SID Numbers to actual users names so I could filter and search for all of their relevant properties.

Once I was able to convert the SID numbers, then i was able to query the databases and prepare a script which will find all Users that were enabled for Lync within the X number of days the user provide as an input.

The script can run in two formats:

1. For querying a specific Lync Pool and X amount of days for searching:

.NewLyncUsersReport-v0.3.ps1 –PoolFQDN [POOLNAME] –HowManyDaysBack [X]

2. For querying a specific Lync pool (and leave the default amount of days on the last 7 days):

.NewLyncUsersReport-v0.3.ps1 –PoolFQDN [POOLNAME]

After the script run it will generate the following report:

image

The script also Email parameters so it can be set as a scheduled task.

Download: TechNet Gallery | OneDrive

5 Comments

  1. Taryel

    wonderful script thanks very much

    Reply
  2. serdar

    so handy. thanks

    Reply
  3. Armando

    Thanks, very useful

    Reply
  4. Aki Stolt

    Hi,

    Great script indeed.

    I have many SIP domain in same pool. How could I list users from just one SIP- domain. Let’s say user that have sip -domain example.com

    Reply
    1. Guy Bachar (Post author)

      It’s a really good idea, i haven’t implemented it in the script, but i would probably change the following line on script and change the domain to whatever you need:

      $tempusr = Get-CsUser -Identity $rowobject.AdUserSid -ErrorAction SilentlyContinue
      to:
      $tempusr = Get-CsUser -Identity $rowobject.AdUserSid -Filter {SIPAddress –like “*@fabrikam.com”} -ErrorAction SilentlyContinue

      Reply

Leave a Comment

Your email address will not be published. Required fields are marked *