This blog is part of a series on Teams. For more articles, check back often
Written: 13/11/2022 | Updated: N/A
On many occasions in my day-to-day role, I am asked how to do specific things within Microsoft 365. And like call outs over social or threads raised up on the Microsoft Tech Community, I always look at these as great opportunities and a rich source of inspiration for the blog. So, this week a good colleague of mine who works at a Microsoft Partner got in touch – and they had a customer who asked them how they could block a specific number which was making nuisance calls to a few of their team. Now, as opposed to implementing user level blocks by the impacted individuals, they wanted to block this number for all users. This meant they wanted to block the number tenant wide. Yet they couldn’t see anything in the Teams Admin Centre how to do it. Solution? Tenant blocking of PSTN numbers can only be done via PowerShell. But thinking on this further, this could really benefit from being an internally managed service in the same way as applying for a blocked app. So, let’s have a looking at blocking which is not just utilized for nuisance calls, but also robocalls, competitor calls and a number of other org specific reasons. It’s good to come around again to a bit of Teams Calling. I always like to keep my hand in.
Let’s go.
This blog will cover
- User Level Inbound PSTN Blocking
- Tenant Level Inbound PSTN Blocking
- Building a Tenant Level Inbound PSTN Blocking Service
- FAQ
Note: this blog may have some abridged steps which will assume some experience with Teams. This blog is using a Ring 4 tenant with GA functionality as well as Microsoft Calling Plans which is the setup of the client’s tenant in this scenario
Prerequisites
- Teams Administrator or Global Administrator for PowerShell
- Microsoft 365 Licence for Teams, Forms, Lists and Power Automate
USER LEVEL INBOUND PSTN BLOCKING
Before we venture into exploring the Tenant Level Inbound PSTN Blocking let’s remind ourselves how we block at the user level. Blocking at the user level means that the number of the Inbound PSTN call is only blocked for that specific user. It won’t be for all users. It won’t block federated calling which can be done by other means. This is just for PSTN.
1.) In the Teams Client select the Calls App

2.) In the Call History select More Options (…) at the top right of the call and then select Block from the dropdown

3.) The number is then marked with a badge as Blocked

4.) To manage the personal blocked users list, select More Options (…) next to the users Avatar and then Settings. Go to Privacy and select Edit Blocked Contacts. Here you can unblock as required.



What is the real-world impact of the block? The answer is really dependent on where you are phoning in from and your telco. Using an iPhone with Vodaphone answer there is a dial tone, but the call rings out and is never answered. The user who is using Teams is never notified, the call is never connected, nor registered in the users call history. So, job done. The user can unblock the number at any time either through the Teams Client Settings under Privacy or via More Options in the Call History against the number.

TENANT LEVEL INBOUND PSTN BLOCKING
Let’s move onto Tenant Level. This is done via PowerShell.
1.) Search for and select Windows PowerShell and Run as Administrator

2.) Ensure that Teams PowerShell Module is installed and then select
Connect-MicrosoftTeams

You may need to authenticate at this point with Administrator Credentials. After authenticating you are ready to go

3.) First the Tenant Block List needs to be Enabled as it’s disabled by default. Use
Set-CsTenantBlockedCallingNumbers -Enabled $true

4.) Now, let’s add a number to the block list. This will start with blocking a fictional UK number of 01234567890 which translates to +441234567890. It is important to note that the 0 prefix is not included. The cmdlet New-CsInboundBlockedNumberPattern is used and along with this a name for the rule is set. A Description and Pattern of the number which is defined by Regex is also set. The command should look like this.
New-CsInboundBlockedNumberPattern -Name "Block+441234567890" -Enabled $True -Description "Block Number +441234567890" -Pattern "^\+?441234567890$"

5.) You would now check this using
Get-CsInboundBlockedNumberPattern

6.) In this example, I will repeat the process adding my own mobile number which I have called Block Mobile

7.) You can test the block with the following command
Test-CsInboundBlockedNumberPattern -PhoneNumber "PhoneNumber"

8. Having tested on my mobile, the experience here was that mobile calling into the tenant could not connect and was dropped immediately 🙂
BUILDING A TENANT LEVEL INBOUND PSTN BLOCKING SERVICE
Whilst setting tenant wide blocks on numbers in PowerShell is powerful, there can be some issues. There is a lack of visibility for the administrator (or administrators if several are maintaining), the process of users asking the administrators to block numbers can be fragmented, and silos of blocked numbers can build up in individual users which leaves others exposed. It would be advantageous if there were a process to submit to administrators which could be make the process easy and give visibility. Here is one way it could be managed
1.) Build a form for users to submit blocked number requests. This would include Name, Email and Number and could have some other information such as a date of request

2.) Create a List. This example was created in Microsoft Teams called PSTN Inbound Number Block List. This has several columns including
- Number
- Name
- Pattern Name
- Pattern Description
- Pattern
- State
As you can see from the columns, this is the information collected from the user request, and the information used in PowerShell for the Inbound Blocked Number Pattern


3.) Build a flow in Power Automate to connect the form and the list, so that when a new request comes in it gets automatically added to the list. An additional flow action can notify the admin team

4.) When the user submits a request, the data is populated into the list for the admin. The list will also work as a list to keep track of the blocked numbers added in PowerShell.






5.) With a little more refinement (and time and testing) you could easily add
- Power Automate to generate the block command for you based on the user response
- Approvals in built into the flow
- Response to the user built into the flow
- Support Number Ranges in the Form and Flow
This could very well be part of a managed service for the customer, ensuring they are safe from the types of calls as earlier identified in this blog
FAQ
Q. Can I add multiple numbers in a number pattern?
A. You can add specific numbers, or ranges. This is defined by Regex.
Q. How do I remove a number pattern?
A. By using the command
Remove-CsInboundBlockedNumberPattern -Identity "Identity"
Q. How should I name Number Patterns?
A. Name them something functional so it is clear what you are blocking. If you are blocking the number 4444 call it ‘Block 4444’
Q. What other in-built features can block calls?
A. At the admin level, the admin can set spam filtering on the Calling Policy and the user can set Block Calls with no caller ID as on which will also aid in reducing bad calls

