ps.outlook.com – Connecting to remote server failed with the following error message

I am receiving the following error when I try to connect exchange online from powershell.

[ps.outlook.com] Connecting to remote server failed with the following error message : The WinRM client cannot process the request because the server name cannot be resolved. For more information, see the about_Remote_Troubleshooting Help topic.
    + CategoryInfo          : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [], PSRemotingTransportException
    + FullyQualifiedErrorId : PSSessionOpenFailed

I am using below command to connect Office 365 using remote PowerShell:

$365Logon = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $365Logon -Authentication Basic -AllowRedirection
Import-PSSession $Session

Solution 1: Run as Administrator

To troubleshoot the error message “Connecting to remote server failed with the following error message: The client cannot connect to the destination specified in the request”, You have to run the Windows PowerShell with elevated privilege ( right click the Windows PowerShell and click “Run as Administrator”).

Solution 2: Connect Office 365 via Proxy Server

This issue also can occur if the Windows PowerShell remoting is affected by proxy settings. To resolve this problem, use proxy setting options in your remote command. The following settings are available: ProxyAccessType, ProxyAuthentication, ProxyCredential

To set these options for a particular command, use the following procedure:

1. Use the ProxyAccessType, ProxyAuthentication, and ProxyCredential parameters of the New-PSSessionOption cmdlet to create a session option object with the proxy settings for your enterprise. Save the option object is a variable.

2. Use the variable that contains the option object as the value of the SessionOption parameter of a New-PSSession command.

$365Logon = Get-Credential

$proxyOptions = New-PSSessionOption -ProxyAccessType IEConfig

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $365Logon -Authentication Basic -AllowRedirection -SessionOption $proxyOptions

Import-PSSession $Session

For more detailed information: please refer to the HOW TO CONFIGURE REMOTING WITH A PROXY SERVER section in the following article: http://technet.microsoft.com/en-us/library/dd347642.aspx 


Source
: https://community.office365.com/en-us/f/148/t/19593

Advertisement

4 thoughts on “ps.outlook.com – Connecting to remote server failed with the following error message”

  1. Thanks so much for this. I've been going round and round in circles for hours trying to work out why I couldn't connect. The Proxy part was the key for me. Much appreciated !

    Reply

Leave a Comment