Whether it’s spam, telemarketing, or general nuisance, interruptions like this to your working day aren’t welcome. Being able to block incoming calls in Microsoft Teams for specific numbers or even entire blocks of numbers is a feature you might welcome but not have known was already there.
Last week, a customer contacted us about an issue they were receiving persistent, unsolicited calls in Microsoft Teams from a phone number. The customer needed a way to block incoming calls from that number and we figured that this was one worth sharing for all to see.
Block incoming calls features in Microsoft Teams
One of the more hidden features in Microsoft Teams is the ability to block incoming calls from a number or a range of numbers at the organisation level. This isn’t something that’s visible or available in the Microsoft Teams Admin Center and requires the use of PowerShell.
The documentation for doing this is neatly tucked away at https://docs.microsoft.com/en-us/microsoftteams/block-inbound-calls.
The feature is enabled at the tenant-level by default but there aren’t any rules applied by default so simply creating some rules automatically starts working. Rules are created using number patterns and are declared as Regular Expressions (Regex).
Once active, rules simply cut the calls off at the other parties end immediately. Depending on the carrier or network used by the person making the incoming call they will either be simply disconnected or they will get a message stating that their call cannot be completed. In the UK, we found, for example, that making a call from a Three mobile phone resulted in the call being dropped with no warning whereas an O2 mobile phone gave the caller the voice prompt.
In our testing of the feature, we found that sometimes new rules take effect within a matter of minutes whereas sometimes they can take several hours. If you are working with the feature to block number(s) then take care firstly to ensure that your Regex patterns are valid using an online tester and also test with Microsoft Teams itself to be sure the rule works as intended.
Block incoming calls from a number
To set-up a block we need to create a new number pattern. This is done using the PowerShell command New-CsInboundBlockedNumberPattern. We give the rule a name and can optionally as a description too which we would recommend making later review and troubleshooting easier.
For the pattern itself, we use a Regex pattern match enclosed in quotes. The number needs to be defined in the E.164 telephone number format which means that it is prefaced with the plus symbol and the country code.
To block a UK mobile phone number, for example, the pattern would look like “^\+447123456789$” substituting the digits shown for those of the number you want to block.
In Regex, the ^ symbol means the start of the pattern string and the $ symbol means the end of the pattern. The backslash symbol before the plus character means to match the plus explicitly. Without this, it doesn’t work.
Block incoming calls for ranges
Being able to block incoming calls for a single number above is easy but what about if you want to block a range of numbers or perhaps all numbers from a particular country? This is where it gets more difficult because although Regex is extremely powerful, a mistype of the pattern could lead to unintentional matches being applied as we’ll show below.
Blocking a specific number range
The first example is where you want to block incoming calls for a range of numbers. Maybe you know that a telemarketing company that is spamming you with calls owns a range of numbers that end between 400 and 499 and you want to block that range only.
The pattern for this looks like “^+4412561234[0-9][0-9]$”. You’ll see the similarity between this at the previous single number pattern but here we say instead that we want to look for any number between 0 and 9 and we do it twice. This, therefore, has the effect of matching all numbers between 400 and 499.
Blocking a wildcard range
This second example is widely applicable to both blocking a large range of numbers such as a whole area code but also useful for blocking an entire country.
Before we get into this one, however, we just need to draw some attention to the implications of it. Because the example below uses a wildcard to identify a part of the number, it means that it’s potentially limitless in how it will match a number. You need to use wildcards with caution because if you set-up the pattern incorrectly, you could block incoming calls for more numbers than you want or expect.
Let’s start by assuming that you want to block all incoming calls from a particular area code, Basingstoke, in this example. The pattern for this would look like “^+441256\d*$”. As you see, the pattern is similar to those previously, however, we now add the \d* syntax which says match any number an unlimited number of times (Regex calls this greedy). With this set, any number that starts with the UK country code and the Basingstoke 01256 area code is blocked.
If we wanted to take this further, we could block an entire country by widening the scope. A rule that looks like “^+7\d*$” then, for example, would block any numbers starting with the Russia country code. This, however, is where it gets complicated.
Let’s say you created a rule with a pattern of “^+1\d*$” that will block all US and Canadian numbers, however, there are other countries which start their country code with 1 but have two or three digits. With the “^+1\d*$” pattern then, you’d also be blocking calls from countries including [but not limited to] Bahamas, Grenada, and Jamaica.
If you wanted to get super fancy, you can block multiple options in a single rule but this does of course add to the complexity and need for testing. A pattern of “^+(7|86)\d*$”, for example, would block incoming calls from both Russia and China.
Get more from Microsoft Teams
If you’ve found this useful and you want to find out how you can make the most out of Microsoft Teams; maybe you are using Microsoft Teams and want to think about how you secure it to both maximise your employee productivity but keep your employees and your business safe, why not contact us at Arcible to find out more.