It is reasonable to think that not all users in your AD are Lync users so there may be times when you will want to know how many Lync users you have. That happened to me the other day as my boss at NextUC asked me that question. So I thought I would show you an easy way to count your users and even tell what type they are.
To get a count of your enterprise voice users you can use this PowerShell snippet:
$list = Get-CsUser | where {$_.LineUri -ne “”}
$list.Count
If you need to see the users you can just write out the contents of $list but in our case we take advantage of the $list.Count method of the $list object to get the total number of enterprise users.
To get a count of your messenger users we just need to modify the PowerShell snippet slightly:
$list = Get-CsUser | where {$_.LineUri -eq “”}
$list.Count
Why not use EnterpriseVoiceEnabled Property?
That’s all there is to it; we simply take advantage of the fact that enterprise users have their phone number in the LineUri property. You may be wondering why I didn’t just check the EnterpriseVoiceEnabled property. Well, in my case I can’t trust the value of EnterpriseVoiceEnabled. We are a hosting company and sometimes I need to temporarily disable an enterprise voice user so I set EnterpriseVoiceEnabled to false but leave the rest of the Lync properties alone. That makes LineUri a more reliable property to use for me but if you don’t have that issue then you could just modify the snippets to use EnterpriseVoiceEnabled.
Nice way of doing it
I made a script to list not only EV users, but also devices, rgs and applications (and give a you a html filem listing them all) http://tech.rundtomrundt.com/2012/04/listing-all-deployed-numbers-in-lync.html
Cool looking script that you wrote. I did something similar to get a list of the DIDs as somtimes the front end portal tries to enable a user for EV with a phone number that is already in use. The error message you get isn’t to useful but I have learned that it means the phone number is already in use.