Releasing Get-SfBNumbers.ps1

As shown at Microsoft Ignite 2015 here is the script demoed called At this time the tool is in beta since it has only been tested in a handfull of deployments.





This script will get the next available number of any provided number range from

  • Unassinged Numbers
  • array in the script
  • parameter input when running the script

It will check for

  • disabled users in Active Directory
  • connect to the LcsCDR to get users that has not logged on for 30 days or more
  • Connect to LcsCDR to check for activity on numbers, both unassigned and assigned

It supports

  • Lync Server 2010, Lync Server 2013, Skype for Business Server 2015
  • Reservation of numbers based on categories like Gold, Silver, Bronze, Special and Excluded
    • From Array in the script or Unassigned Numbers
  • Reservations of number ranges within larger number ranges for special services like future callcenter or response groups
  • Retention of numbers based on disabled in Active Directory, last logon time and activity on numbers

Reporting supported

  • Default behaviour is GridView with all numbers and summary in the PowerShell window
  • Export to of all information to CSV
  • Create a summary in PieChart as HTML




16 thoughts on “Releasing Get-SfBNumbers.ps1

  1. Wow, what a great script!

    Two things, one, in your examples, you have the following line: “.\Get-SfBNumbers.ps1 -AllRanges $True -ReportGrid $True -ReportPieChartHTML $True” but looking at the script, appears that the correct statement is: “-ReportHTML”

    Also, I’m getting the following error: “Get-CsRgsWorkflow : A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found…..”

    Is there a specific configuration I need to have in an Enterprise deployment (SQL in the back)? The Reporting services are available, and verified.


    • -ReportPieChartHTML is the correct one, returns the piecharts in htlm. -ReportHTML has no action at the moment and is reserved for future htlm to email report, or so it was intended. Will double check for the next update :)

  2. Get-CsMeetingRoom doesn’t exist on Lync 2010

    The script has been stuck on “Finding all numbers in ranges…” for an hour and the ISE capped at 400MB of memory. I finally stopped the script so I didn’t end up triggering a monitoring threshold for memory utilization on one of my FE servers.

    I’ll try again when I have time to go through all the script comments, probably user error.

  3. Hi. Thanks for both the script and the intro @msignite. I’m trying to implement the script and getting to learn it.
    I’m gettings errors when connecting to the CDR. Have tried it on both a standard edition and enterprise edition pool (mirrored). The context of which the scripts run has access to the monitor reports through the same server as the scripts runs at. Running it from a FE server.
    One more thing. It seems when looking at ranges with users on a SBA that information is missing. Example voicepolicy. Empty in the output but fine when doing a “manual” get-csuser -identity | fl
    Best regards
    Torsten Egebirk

    • Great feedback Torsten. The SQL instance connection is something I am working on for the next version in order for it to be more resilient. I too find it strange that the voice policy does not show up for SBA usrs, since it is using the very same cmdlet you are using manually. I will need to look in to that at one point.

      Look for an update in about a month, hopefully before that.

      • Hi Ståle
        My bad about the Voicepolicy. The number range “on the” SBA was taken from unassigned number range. And in that there was a misconfiguration. I just added the number range in the script in the “Phone Number Range Database” then Voicepolicy information was ok. Still stuck at the CDR connection

  4. Hello, Ståle..

    the script hangs at “Adding user call activity to internal database” on Skype for Business RTM

    • In Lync Server 2013 I have the same problem. Worked ok in my lab but in production hangs on “Adding user call activity to internal database..”. All preceding setps are OK.

  5. Hi Ståle,

    This could just be me, but I have a few installs all with the script working as expected, with the exception of the “FirstavailableExtension”. I had had a look through the script and been able to edit it to get the required number of digits for the extension, some customers have 4 (looks like the script default), some have 4 and some have 5, but is there a way in the set-up of the script to change the extension length without having to edit the script itself?



  6. Hi,

    At first great script and thanks for sharing. A few remarks to the version from: 5/12/2015. I had to make the following corrections to make the script work:

    – Missing parameter in the begining of the script: $ReportPieChartHTML=$false
    – Missing closing } ending the function Function Report-PieChartHTML($FunctionReport)
    – Extra } after Function Create-PieChart(), which is not needed
    – The script used to get stuck on “Adding user call activity to internal database” in my production environment too due to a huge number of records when calling function $NumberActivity = Check-NumberActivity(30), $ReturnValue would be 51k records and the script would process around 1 number a second.. I personally had to hash thiis function until a more efficient way is found



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s