This PowerShell script which collects assigned and unassigned phone numbers from Microsoft Teams and shows you where they are used. The script supports Users, Meeting Rooms, Online Application Instances (Resource Accounts) and Dial-in Conference numbers.
The script can output the results to the console or to a CSV.
Example output:
Note: A version of my script that has been enhanced by Ruud van Strijp is available here. Extra features at the time of writing:
- Changed login method and file save location. Added HTML export by default
- Added UPN. Added HTML table width for better readability
- Added EV columns; Calling and Voice Routing Policies
- Changed for module 3.0.0
- Get Dial Plan, fix first name, merge Resource Account and User, make table wider
Great work! This script helped me to finally identify a phone number I couldn’t for the life of me find in the system. Exactly what I was looking for 🙂
I did have to make a few tweaks though to get it to generate a complete list of phone numbers as I was hitting limits on the functions. Presumably you were working with a smaller dataset. Specifically:
– Add ‘-All’ to the Get-MsolUser function
– Turns out the Get-CsPhoneNumberAssignment only returns max 500 numbers, got around this by implementing the fix described here: https://robdy.io/all-available-numbers-calling-plan/
I also set the csv path to where the script is executed from (as opposed to a static path) and fixed the misspellings on lines 86 and 92 (assigne -> assigned).
Great to hear that it helped you :). Hadn’t spotted those limitations so I will try and get around to implementing those changes. Thanks for sharing!
This is great for listing all the assigned numbers within our system, as well as their AssignmentType.
However, I’m struggling to find a functional method to yield abandoned/unassigned numbers within our Teams tenant.
Two scenarios I can think of within our environment where this would be required. Eg:
> Staff member has a DDI assigned within Microsoft Teams and uses it as their telephony solution.
> Staff member leaves the company.
> Account is disabled, causing the number to become orphaned.
> Number is technically still within our Microsoft Teams Tenant, but not assigned to anyone and not yieldable via PowerShell scripts like this and other ones, as well as not being listed in the portal.
> Requires us to write down the number somewhere so we know it exists and can be assigned to someone else in the future.
It would be great if there’s an appropriate cmdlet to yield what numbers are within our Tenant but not assigned to any object to stop us having to maintain a list of numbers which aren’t assigned.
Any ideas on this? Greatly appreciated.
I don’t have a solution unfortunately.
When I wrote this tool for SfB (https://theucguys.com/call-flow-manager/) I used the unassigned number ranges in SfB to compare to assigned numbers, This returned a list of available numbers.
Teams has only recently supported unassigned numbers and I haven’t looked into how I could do the same (https://learn.microsoft.com/en-us/microsoftteams/routing-calls-to-unassigned-numbers).
I friend of mine wrote a tool that might help:
Video: https://www.youtube.com/watch?v=m3_gN60TMJo
Download: https://ucsorted-my.sharepoint.com/personal/paul_ucsorted_com/_layouts/15/onedrive.aspx?id=%2Fpersonal%2Fpaul%5Fucsorted%5Fcom%2FDocuments%2FPublic%20Share&ga=1
You’ll still need a CSV of all your numbers. But it does a check against assigned.
Hope that helps 🙂