New-ExoPSSesion : Connecting to Remote Server outlook.office365.com Failed

The client cannot connect to the destination specified in the request.

In some cases, you’ll see the following error message when connecting to Exchange Online using the EXO2 PowerShell module:

New-ExoPSSession : Connecting to remote server outlook.office365.com failed with the following error message :
The client cannot connect to the destination specified in the request.
Verify that the service on the destination is running and is accepting requests.
Consult the logs and documentation for the WS-Management service running on the destination,
most commonly IIS or WinRM.
If the destination is the WinRM service, run the following command on the destination to analyze and configure
the WinRM service: "winrm quickconfig".
For more information, see the about_Remote_Troubleshooting Help topic.

Please access Microsoft’s cloud Exchange environment and check that the WS-management service is running! 😁

Contrary to what this error message indicates, you should naturally look for the cause of the error on your local system.

There can be multiple causes to why your system is unable to complete the connection request.

One problem could be an invalid proxy setting. If, e.g., you are playing around with Fiddler or other tools and setting up local proxy settings, you could accidentally block the EXO connection request.

Check for bogus proxy settings using the following command:

PS C:\> netsh winhttp show proxy

Current WinHTTP proxy settings:

    Proxy Server(s) :  localhost:8888
    Bypass List     :  (none)

If you find any (invalid) active proxy settings, you can clean them up using the following command:

PS C:\> netsh winhttp reset proxy

Current WinHTTP proxy settings:

    Direct access (no proxy server).

PS C:\> netsh winhttp show proxy

Current WinHTTP proxy settings:

    Direct access (no proxy server).

With these settings out of the way, you should be back in business:

PS C:\WINDOWS\system32> Connect-ExchangeOnline

----------------------------------------------------------------------------
The module allows access to all existing remote PowerShell (V1) cmdlets in addition to
the 9 new, faster, and more reliable cmdlets.

|--------------------------------------------------------------------------|
|    Old Cmdlets                    |    New/Reliable/Faster Cmdlets       |
|--------------------------------------------------------------------------|
|    Get-CASMailbox                 |    Get-EXOCASMailbox                 |
|    Get-Mailbox                    |    Get-EXOMailbox                    |
|    Get-MailboxFolderPermission    |    Get-EXOMailboxFolderPermission    |
|    Get-MailboxFolderStatistics    |    Get-EXOMailboxFolderStatistics    |
|    Get-MailboxPermission          |    Get-EXOMailboxPermission          |
|    Get-MailboxStatistics          |    Get-EXOMailboxStatistics          |
|    Get-MobileDeviceStatistics     |    Get-EXOMobileDeviceStatistics     |
|    Get-Recipient                  |    Get-EXORecipient                  |
|    Get-RecipientPermission        |    Get-EXORecipientPermission        |
|--------------------------------------------------------------------------|

To get additional information, run: Get-Help Connect-ExchangeOnline or check
https://aka.ms/exops-docs

Send your product improvement suggestions and feedback to exocmdletpreview@service.microsoft.com.
For issues related to the module, contact Microsoft support.
Don't use the feedback alias for problems or support issues.
----------------------------------------------------------------------------