«

»

Oct 13

Make a Lync Phone Book

Had the idea today that I wanted to export a list of all users and their phone numbers. You know – just like a phone book. So I fired up Powershell, copied a bunch of other people’s snippets and came up with the following:

Get-CsUser -filter {LineURI -ne $Null} | Sort-Object DisplayName | Select-Object Displayname, Registrarpool, LineURI | export-csv phonebook.csv

Run that and you get something like this:

Breaking down the command briefly, it works like so:

We want to filter out users with no phone number, so if the LineURI is empty (i.e., Null) then skip that user.

Next I decided to sort on the DisplayName.

From the output of the CSUser command, we only want to pull out the values DisplayName, RegistrarPool, and LineURI.

Finally, we export it as a .csv so you can do any additional slicing and dicing in Excel.

Here’s another command I used to only show the people in a certain office:

Get-CsUser -filter {(VoicePolicy -eq ‘NYC-National’) -or (VoicePolicy -eq ‘NYC-International’)} | Sort-Object DisplayName | Select-Object Displayname, Registrarpool, LineURI

In this case, I am filtering based on people assigned a specific Voice Policy.

———-

On a separate approach, we are looking to migrate all of our users to the same dial plan. In order to generate a list of those users, I ran the following:

Get-CsUser -filter {(Dialplan -ne “Good_Plan”) -and (LineUri -ne $NULL)} | Sort-Object DisplayName | Select-Object Displayname, Registrarpool, LineURI | export-csv wrong_plan.csv

The first part of the filter finds everyone who is NOT using the plan we want to continue with, i.e. Good_Plan. The second part of the filter makes sure everyone returned has a defined phone number (LineURI). Without this second one added in, it returns user who have not yet been configured for enterprise voice. And since they have not yet been configured, they have no value in the Dialplan field.

1 ping

  1. Lync Mobility Policy « Thoughts From a Böt Named Flinch

    […] on this post of mine, we can build a powershell command to export a list of all users enabled for a specific […]

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

%d bloggers like this: