question

LucasLiu-MSFT avatar image
0 Votes"
LucasLiu-MSFT asked TimWitham-7600 answered

[Migrated from MSDN Exchange Dev]Intermittingly failing New-Pssession to Exchange Online https://outlook.office365.com/powershell-liveid/

[Note] This thread was originally posted on MSDN. As the MSDN Exchange Dev forum mainly focuses on developing issues and the TechNet Exchange forums for general questions have been locked down, we manually migrated this one to Microsoft Q&A platform to continue the troubleshooting.


Hi, I have a script written for to set mailbox quotas on ExchangeOnline. I am validating licenses and service plan in O365 License assigned to User before setting Mailbox quotas.

But while establishing a PSsession with "https://outlook.office365.com/powershell-liveid/". It fails 6/10 times with this error.

[New-PSSession|2613] Failed to connect to exchange online. |Reason: Connecting to remote server outlook.office365.com failed with the following error message : The SSL connection cannot be established. Verify that the service on the remote host is properly configured to listen for HTTPS 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 -transport:https". For more information, see the about_Remote_Troubleshooting Help topic.

Any help would be appreciated.

office-exchange-online-itprooffice-exchange-server-connectivity
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

LucasLiu-MSFT avatar image
0 Votes"
LucasLiu-MSFT answered

Hi,
Does this problem only occur occasionally?
What is the command line you are running, please make sure you run the correct command line.
What’s the version of your Windows server?For the old version of Windows, you need to install the Microsoft .NET Framework 4.5 or later and then an updated version of the Windows Management Framework: 3.0 or 4.0 or 5.1 .
Please run the "winrm quickconfig -transport:https" in CMD start as administrator and see how it turns out. WinRM HTTPS requires a local computer Server Authentication certificate with a CN matching the hostname, that is not expired, revoked, or self-signed to be installed.
For more information you could refer to: How to configure WINRM for HTTPS



If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.




5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

TimWitham-7600 avatar image
0 Votes"
TimWitham-7600 answered

We had a similar issue with connections to Office365 periodically failing with the same error.

Turns out the issue wasn't with Windows Remote Management (WinRM) but another process limiting what security protocols could be used, which was stopping the powershell session (`New-PSSession`) for https://outlook.office365.com/powershell-liveid/ from being established. Resolved by adding TLS 1.2 prior to the session being created, i.e.;

[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12

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

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.