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
2021-09-09T16:54:26.393+00:00

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.
9,129 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.
5,382 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 39,376 Reputation points
    2021-09-13T10:51:38.577+00:00

    Hello,

    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.

    https://learn.microsoft.com/en-us/microsoft-365/enterprise/connect-to-all-microsoft-365-services-in-a-single-windows-powershell-window?view=o365-worldwide

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