When I use this command New-CsOnlinePSTNGateway, powershell send an error Get-CsOnlineSession : The remote server returned an error: (403) Forbidden

Hugo Sánchez Sánchez 1 Reputation point

PS C:\Windows\system32> New-CsOnlinePSTNGateway -Fqdn essbc2.sip4teams.com -SipSignalingPort 5082 -Enabled $true
Get-CsOnlineSession : The remote server returned an error: (403) Forbidden.
At C:\Program Files\WindowsPowerShell\Modules\MicrosoftTeams\2.5.1\net472\SfBORemotePowershellModule.psm1:273 char:22

  • $remoteSession = & (Get-CsOnlineSessionCommand)
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • CategoryInfo : NotSpecified: (:) [Get-CsOnlineSession], WebException
  • FullyQualifiedErrorId : WebException,Microsoft.Teams.ConfigApi.Cmdlets.GetCsOnlineSession

Invoke-Command : Cannot validate argument on parameter 'Session'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
At C:\Program Files\WindowsPowerShell\Modules\MicrosoftTeams\2.5.1\net472\SfBORemotePowershellModule.psm1:113 char:38

  • -Session $session `
  • ~~~~~~~~
  • CategoryInfo : InvalidData: (:) [Invoke-Command], ParentContainsErrorRecordException
  • FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeCommandCommand
Microsoft Teams
Microsoft Teams
A Microsoft customizable chat-based workspace.
6,733 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
4,907 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 37,786 Reputation points


    Thank you for your question.

    I would like to suggest you below troubleshooting steps.

    Run the powershell command in Normal powershell window instead of ISE.

    Also ,Please have a look on below Microsoft article mentioning how to connect to different Microsoft services using poweshell.


    If the reply was helpful, please don’t forget to upvote or accept as answer.