Solved Can't execute dial plan script

Status
Not open for further replies.

dk812

Customer
Joined
Jan 24, 2022
Messages
9
Reaction score
1
Hello! When I run the script after installing Microsoft Teams powershell module it ctreated only this one:
New-CsOnlinePSTNGateway -Fqdn teams.chemservice.su -Enabled $true -SipSignalingPort 5062 -MaxConcurrentSessions 100 -ForwardCallHistory $true -ForwardPai $true

As for others commands it stopped at:
Set-CsOnlinePstnUsage -Identity Global -Usage @{add="3CX PSTN Usage"}
saying the following:
PS C:\Teams> Set-CsOnlinePstnUsage -Identity Global -Usage @{add="3CX PSTN Usage"}
Set-CsOnlinePstnUsage : Unable to cast object of type 'System.Management.Automation.PSListModifier' to type 'System.Str
ing'.
строка:1 знак:1
+ Set-CsOnlinePstnUsage -Identity Global -Usage @{add="3CX PSTN Usage"}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: :)) [Set-CsOnlinePstnUsage], InvalidCastException
+ FullyQualifiedErrorId : System.InvalidCastException,Microsoft.Rtc.Management.Internal.SetOnlinePstnUsageCmdlet
What is the problem?
 
Hi!

I just re-tried this command on an up-to-date Win10 machine and it executed without any problems.
I would personally suggest checking for Windows Updates, and also re-run the PS command Install-Module -Name MicrosoftTeams to make sure you have the latest version of the module installed.

Of course all this must be done with a Powershell that you have ran using "Run as Administrator".

If this doesn't help, I would also suggest trying from another PC as I have heard of cases where some PS modules are 'broken' on the OS.
 
  • Like
Reactions: Evolute IT
Hello. Thank you for answering. I'll check and back. One more question about e164 format number in caller id. We always had format of caller id for users without "+". After reading manual of connecting Teams to 3CX, it is a must to have + before the office number. Will we have any problems if our VOIP providers doesn't accept it? If I disable such a feature in the settings of 3CX, can I leave caller id for users just like numbers (for example 147, but not +147)?
 
Hi!

I just re-tried this command on an up-to-date Win10 machine and it executed without any problems.
I would personally suggest checking for Windows Updates, and also re-run the PS command Install-Module -Name MicrosoftTeams to make sure you have the latest version of the module installed.

Of course all this must be done with a Powershell that you have ran using "Run as Administrator".

If this doesn't help, I would also suggest trying from another PC as I have heard of cases where some PS modules are 'broken' on the OS.
I've tried again on the virtual machine (Windows 2019 Server) and Windows 10 with last updates on both. Still the same error message.
 
Hello. Thank you for answering. I'll check and back. One more question about e164 format number in caller id. We always had format of caller id for users without "+". After reading manual of connecting Teams to 3CX, it is a must to have + before the office number. Will we have any problems if our VOIP providers doesn't accept it? If I disable such a feature in the settings of 3CX, can I leave caller id for users just like numbers (for example 147, but not +147)?
If your provider doesn't accept dialing numbers in e164 format, you will have to make sure you reformat the number using the 3CX Outbound Rules. The dialed number from Teams will always leave in a e164 format, so you need to adjust it in the Outbound Rules.


I've tried again on the virtual machine (Windows 2019 Server) and Windows 10 with last updates on both. Still the same error message.
Just to make sure, you have opened a PowerShell with "Run as Administrator" and you have manually, not by executing the PS1 file generated from the Management Console, ran these commands:
Code:
Install-Module -Name MicrosoftTeams
Connect-MicrosoftTeams
Set-CsOnlinePstnUsage -Identity Global -Usage @{add="3CX PSTN Usage"}

And you are getting this error, correct?
 
If your provider doesn't accept dialing numbers in e164 format, you will have to make sure you reformat the number using the 3CX Outbound Rules. The dialed number from Teams will always leave in a e164 format, so you need to adjust it in the Outbound Rules.



Just to make sure, you have opened a PowerShell with "Run as Administrator" and you have manually, not by executing the PS1 file generated from the Management Console, ran these commands:
Code:
Install-Module -Name MicrosoftTeams
Connect-MicrosoftTeams
Set-CsOnlinePstnUsage -Identity Global -Usage @{add="3CX PSTN Usage"}

And you are getting this error, correct?
Yes, correct. When I execute the ps1 file i got the following:
New-CsOnlinePSTNGateway : "OnlinePSTNGateway" with id "teams.chemservice.su" exist. Actully it's really exist and it was successfully added by executing ps1 file but other commands failed for execution.
 
We managed to fix the issue after downgrading the "MicrosoftTeams" Powershell module to v3.0.0 from v3.1.0.
After this the command no longer threw any error.
 
  • Like
Reactions: Evolute IT
Just an update on this, for anyone else receiving the following error when running the Teams Dial Plan powershell script:


Set-CsOnlinePstnUsage : Unable to cast object of type 'System.Management.Automation.PSListModifier' to type 'System.String'.
At line:1 char:1
+ Set-CsOnlinePstnUsage -Identity Global -Usage @{add="3CX PSTN Usage"}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: :)) [Set-CsOnlinePstnUsage], InvalidCastException
+ FullyQualifiedErrorId : System.InvalidCastException,Microsoft.Rtc.Management.Internal.SetOnlinePstnUsageCmdlet


We have communicated with Microsoft Support and they have confirmed that there is an issue with Microsoft Teams cmdlets module v3.1.0 and suggest to downgrade to an older version.

To confirm that you have this version, in powershell execute:
Code:
Get-InstalledModule -Name "MicrosoftTeams"

If you do have v3.1.0 installed, in order to downgrade to the last known version that works at the time of writing this post, you can run the the following commands:
Code:
Uninstall-Module MicrosoftTeams -Allversions
Install-Module -Name MicrosoftTeams -RequiredVersion 3.0.0

After you do this, the script generated by 3CX should be able to run without returning this error.
 
  • Like
Reactions: dk812
Status
Not open for further replies.