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.
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:
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:
The script also Email parameters so it can be set as a scheduled task.