DON'T REINVENT THE COW

This is a place for Systems Administrators and IT Professionals to find and share ideas, solutions and templates. If you have something that helps you solve a problem, chances are it will help someone else too. So pay it forward and send an email to TheAgreeableCow at gmail. Full mudos to you!

Tuesday, 5 June 2012

Getting Unassigned Numbers in Lync 2010

So picture the scenario, you've got a new user starting tomorrow and you need to assign them a phone number. But which number? One of the complexities with any domain integrated VOIP system is keeping some sort of control over the allocation of phone numbers. You may very well have an up to date phone list, but Active Directory and Lync don't really care about your über Excel skills.

Check out Ståle Hansen's blog post for his original script that did a brilliant job solving this problem. The updated script below runs from your Windows 7 machine and presents a list of phone numbers that are either Assigned or Unassigned for your choosing.

In large enviornments covering multiple sites, this could still be a complex result set. So rather than just throwing out a list of potentially hundreds of numbers, the script compares the numbers it finds against the "Unassigned Number Range" feature in Lync. This is primarily used to play a message or redirect a call if someone accidentally calls a number that has not been assigned to anyone. Here's a Technet article with more information.

In our environment, we simply redirect these calls to reception. The ranges were setup for each site, corresponding to each contiguous block of numbers that we had been allocated by the phone company eg 1234 1200 to 1234 1299. We're not going to do any redirection with this script, just use the ranges to provide some measure of control for selecting and displaying results.


The script checks a series of phone number repositories using typical Lync shell cmdlets such as Get-CsUser and Get-CsAnalogDevice. All up this includes:
  • User numbers (including Private Number)
  • Analogue Devices
  • Common Area Phones
  • AutoAttendant numbers
  • Dial In Access Numbers
  • Trusted Application Endpoints
  • Response Groups
As the script runs it queries each range, advises how many numbers are in use and prompts for an action to either show the Unassigned Numbers, the Assigned Numbers or to skip that range and move on to the next one. 



Here is the complete code.


 Cheers,
         (__)
         (oo)  ok
   /------\/  /
  / |    ||
 *  /\---/\
    ^^   ^^



No comments:

Post a comment