Manage MS Teams Call-forwarding in Powershell

Yes, this is finally possible – with the MicrosoftTeams 3.0.1 preview Powershell module came a set of super handy new cmd-lets for controlling Call forwarding for all users, and also for control og delegates and local Call groups.

To get this to work you need to forcefully install the previews Powershell module

https://www.powershellgallery.com/packages/MicrosoftTeams/3.0.1-preview

Do that by running these to commands in Powershell (Note you need minimum of Powershell v 5.1 for this locally)

Install-Module -Name MicrosoftTeams -AllowPrerelease -force
Import-Module MicrosoftTeams -force

This gives a handfull of new cmd-lets.

In this article i will highlight to control of Calling Settings – meaning forwarding, simultaneous and unaswered call settings.
(Note- there is no “remove-csusercallingsettings”, the set command is used for this with setting -isforwardingenabled)

FLOW of Set-CsUserCallingSettings

To better understand how this cmd-let works i created a drawing . Imagine the flow through the parameters and settings, when you create the wanted setting for a user.

The Legend shows:

Green box is Boolean values, so either $True og $False
Yellow selections are Parameters
Purple squares are Values for the forwarding method
Blue boxes are Values for type of forwardingtarget
Lastly the Polygon is a Stringvalue representing the target itself.

So lets create a couple of examples:

Lets say i want the user tjo@juhlconsult.dk to have ALL calls forwarded to user ral@juhlconsult.dk
So i put in
Set-CsUserCallingSettings -Identity tjo@juhlconsult.dk -IsForwardingEnabled $true -ForwardingType immediate -ForwardingTargetType singleTarget -ForwardingTarget “ral@juhlconsult.dk”

And my client immediately reflects this:

Lets say i want the user tjo@juhlconsult.dk to have ALL calls ringing simultaneously on his mobile

So i put in:
Set-CsUserCallingSettings -Identity tjo@juhlconsult.dk -IsForwardingEnabled $true -ForwardingType simultaneous -ForwardingTargetType singleTarget -ForwardingTarget “+45xxxxxxxx”
And my client immediately reflects this:

FLOW for Unanswered calls

When you want to control actions for unanswered calls, its the same cmd-let, but behaviour and parameters are different. So here is the flow:

Lets say i want the user tjo@juhlconsult.dk to have ALL unanswered calls going to voicemail

So i put in:
Set-CsUserCallingSettings -Identity tjo@juhlconsult.dk -IsUnansweredEnabled $true -UnansweredDelay 00:00:30 -UnansweredTargetType Voicemail
OR maybe instead have unaswered Calls go to the Reception or maybe an Auto Attendant:
You can find the name/adress for the AA inside Azure AD if in doubt, in my case its rather long.

Set-CsUserCallingSettings -Identity tjo@juhlconsult.dk -IsUnansweredEnabled $true -UnansweredDelay 00:00:30 -UnansweredTargetType singleTarget -UnansweredTarget “oaa_89558f4d43de4117b48be9861b23efae@juhlconsult.dk”

And this is again immediately reflected in the client.

For both the flow for Unanswered and Forwarding there is a couple of caveats worth noting:

If using MyDelegates, these need to be defined FIRST, for it to work
If using “group” setting, you need to define the group in Powershell first – I will do an example for that below.
The setting “VoiceMail” is not available of you set “forwardingtype to Immediate.

Example for controlling forwarding to a group of people:

$mygroup = @(“ral@juhlconsult.dk”)
Set-CsUserCallingSettings -Identity tjo@juhlconsult.dk -CallGroupOrder InOrder -CallGroupTargets $mygroup
Set-CsUserCallingSettings -Identity tjo@juhlconsult.dk -IsForwardingEnabled $true -ForwardingType Immediate -ForwardingTargetType Group

Run the above in sequence.

Lets have a look in the client, note 2 thing happened, a local Call group was created in this case with one single member, and that group was then selected as target for Forwards.

On the Technet article documenting the cmd-let there are even more advanced scenarios, where you control, the Call Group, the change of an existing Call group, and even the notification settings

$ucs = Get-CsUserCallingSettings -Identity user1@contoso.com $cgt = {$ucs.CallGroupTargets}.Invoke() $cgt.Add(“user5@contoso.com”) $cgt.Remove(“user6@contoso.com”)
Set-CsUserCallingSettings -Identity user1@contoso.com -CallGroupOrder $ucs.CallGroupOrder -CallGroupTargets $cgt $gmd = (Get-CsUserCallingSettings -Identity user5@contoso.com).GroupMembershipDetails $gmd[[array]::IndexOf($gmd.CallGroupOwnerId,’user1@contoso.com’)].NotificationSetting = ‘Banner’
Set-CsUserCallingSettings -Identity user5@contoso.com -GroupMembershipDetails $gmd

This example shows how to update the call group of user1@contoso.com to add user5@contoso.com and remove user6@contoso.com. In addition the notification setting for user5@contoso.com for user1@contoso.com’s call group is set to Banner.

The key to note here is the call group membership is defined on the object of the owner of the call group, in the above case this is user1@contoso.com. However the notification setting for a member for a particular call group is defined on the member. In this case user5@contoso.com. (Source https://docs.microsoft.com/en-us/powershell/module/teams/set-csusercallingsettings?view=teams-ps)

So the use cases for theese new commands are many, and the ability alone to control this remotely and in bulk for users is a GREAT addition.

Have a great day.

Leave a Reply

Your email address will not be published. Required fields are marked *