Get-AssignedLineURI.ps1 v 3_5 released

I am still going through my scripts and verifying how they work on Skype for Business server. Get-AssignedLineURI was next in line. And as with my other scripts, I have taken the time to fix minor bugs and add features to the releases. Here are the highlights of version 3.5:

  • Code Cleanup: Moving parameters into sets, to avoid unintentional errors
  • New feature: Listing users enabled for EV, but without a lineURI present
  • New feature: Listing users disabled for EV, but with a lineURI present
  • More information: Added sip domain to the output of the search
  • Beta feature: Get the unassigned numbers from CsUnassignedNumber and quicly identify available numbers, First, first 10 or entire list
  • Beta feature: Manual number range for the unused assigned section

Moving parameters into sets, to avoid unintentional errors

As the scripts grow, they tend to have more switches added. Some of these could actually make the other not work. And to avoid conflicting switches, I have moved them into sets. Run “get-help .\get-assignedlineuri.ps1” to get a clear view of the possible combinations (or read the help file).

Listing users enabled for EV, but without a lineURI present and Listing users disabled for EV, but with a lineURI present

It is not uncommon  to make mistakes when working with EV. Two of the most common mistakes I run into is when admins disable enterprise voice and forget to remove it from the LineURI, or removes the LineURI and forget to disable EV. The first scenario doesn’t free up the number, and the second scenario still requires a EV license for the user. I used to run one-liners at deployments, to identify these “errors”, but decided I could use this script instead.

To identify if you have one the following issues, simply use the -ShowSummaryInShell switch:


To identify these objects, use the -CreateHTMLOutput switch and study the outputfile:




Get the unassigned numbers from CsUnassignedNumber range

As the script was made to gather all the lineuri’s in the deployment, it was easy to incorporate a switch to identify non-used numbers based of the unassigned range:


Manual number range for the unused assigned section

And while I was at it, I created an option to provide a manual start and end range. This way it’s is easy to find a number in a specific range, and the script doesn’t have to go through all your ranges to find just on number.



License information

I have also gone through the license information output, and I think the new output makes more sense:



The script is available for download at the Technet Gallery

I hope you find these changes useful. And as always, I appreciate feedback ;)


5 thoughts on “Get-AssignedLineURI.ps1 v 3_5 released

  1. Hi Lasse,
    Is it possible to replace privateline with AD telephoneNumber attribute and fetch the data from AD.
    so that, we can make sure the telephone number in AD and Lync LineURI matches for users.

    • Hi,
      That would of course be possible, but it was not my intention with this script.
      I’ll give it a thought, and see if it makes sense to incorporate in a future release.


  2. Hi Lasse. First of all, you’re awesome! Thanks for the scripts. I’m just curious about the “error messages” i’m getting. The script works, but I do get some errors. I notice you have listed one known bug, “To be fixed: An error related to deployments where there are more than one CMS instance returned by get-csservice -CentralManagement “. I believe all my errors (except the Get-CsExUMContact) are related to that, correct? The other seems to not be supported anymore in PowerShell. See below.

    Get-CsPool : Cannot convert ‘System.Object[]’ to the type ‘Microsoft.Rtc.Management.Xds.XdsGlobalRelativeIdentity’
    required by parameter ‘Identity’. Specified method is not supported.
    At C:\Get-AssignedLineURI.ps1:722 char:38
    + $testPool = get-cspool -Identity $($CMS.PoolFqdn)
    + ~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (:) [Get-CsPool], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgument,Microsoft.Rtc.Management.Xds.GetPoolCmdlet

    You cannot call a method on a null-valued expression.
    At C:\Get-AssignedLineURI.ps1:723 char:5
    + $testmachine = $testPool.computers.split(“,”)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    Get-CsManagementStoreReplicationStatus : Cannot validate argument on parameter ‘ReplicaFqdn’. The argument is null or
    empty. Supply an argument that is not null or empty and then try the command again.
    At C:\Get-AssignedLineURI.ps1:727 char:73
    + $testversion = (Get-CsManagementStoreReplicationStatus -ReplicaFqdn $testmac …
    + ~~~~~~~~
    + CategoryInfo : InvalidData: (:) [Get-CsManagementStoreReplicationStatus], ParameterBindingValidationExc
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Rtc.Management.Xds.GetOcsManagementStoreRepli

    Cannot run the cmdlet: “Get-CsExUmContact” because it is restricted for the tenant service plan: MCOProfessional.
    + CategoryInfo : PermissionDenied: (Get-CsExUmContact:String) [Get-CsExUmContact], UnauthorizedAccessExce
    + FullyQualifiedErrorId : UnAuthorized,Microsoft.Rtc.Management.AD.Cmdlets.GetCsUmContactCmdlet
    + PSComputerName :

    Exception calling “Substring” with “1” argument(s): “startIndex cannot be larger than length of string.
    Parameter name: startIndex”
    At C:\Get-AssignedLineURI.ps1:413 char:21
    + $xIT | Add-Member -MemberType NoteProperty -Name “Type” -Val …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ArgumentOutOfRangeException

    • Yes, that error seems to be related to the CMS bug (which I thank you for reminding me about :) )
      The other I am not sure. I just ran this in my own environment, and did not see that error message. Are you running Exchange in O365 only, or SfB?

    • Doug,
      Can you do me a huge favor?

      Run this piece of code in Powershell:
      $CMS = get-csservice -CentralManagement
      $CMS = $CMS[0]
      $testPool = get-cspool -Identity $($CMS.PoolFqdn)
      $testmachine = $testPool.computers.split(“,”)
      if ($testmachine.count -gt “1”){
      $testmachine = $testmachine[0]

      It’s the same as in the script (Line 721-726), but I have added the $CMS = $CMS[0] to try to single out one of multiple entries if it exists.

      The code should not shout out any errors, but only return one server ($testmachine)

      If you could do this and let me know, I could release a new version shortly.

      Really appreciate the help.

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