Powershell: Can not connect to Office 365 with PowerShell on macOS - Client did not get proper response from server.

Created on 13 Jun 2018  路  13Comments  路  Source: PowerShell/PowerShell

Steps to reproduce

Install either PowerShell v6.0.2 or 6.1.0-preview.2 on macOS 10.13.5
Open a new session to Office 365 via

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

Expected behavior

The expected behaviour is as per Windows where PowerShell connects to Office 365 and begins downloading modules.

Actual behavior

Instead we receive an error message:
New-PSSession : [outlook.office365.com] Connecting to remote server outlook.office365.com failed with the following error message : Client did not get proper response from server.

Environment data

PS /Users/kai> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.1.0-preview.2
PSEdition                      Core
GitCommitId                    v6.1.0-preview.2
OS                             Darwin 17.6.0 Darwin Kernel Version 17.6.0: Tue May  8 15:22:16 PDT 2018; root:xnu-4570.61.1~1/RELEASE_X86_64
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Full output from PowerShell

PS /Users/kai> $cred = Get-Credential                                                                                                                                       

PowerShell credential request
Enter your credentials.
User: [email protected]
Password for user [email protected]: ********

PS /Users/kai> New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $cred -Authentication "Basic" -AllowRedirection                                                                                                                                                        
New-PSSession : [outlook.office365.com] Connecting to remote server outlook.office365.com failed with the following error message : Client did not get proper response from server. For more information, see the about_Remote_Troubleshooting Help topic.
At line:1 char:1
+ New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "h ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : 1,PSSessionOpenFailed
Issue-Question Resolution-Answered Resolution-Duplicate WG-Remoting

All 13 comments

@kai-h Please try Preview3 build.

No good for me. Now, I've done a clean install as I was having other issues on this Mac, but I've followed the setup instructions I've used previously to get pwsh to link to the MacPorts OpenSSL libraries, so it should be as it was before.

When I installed Preview3, it didn't install a pwsh binary, but instead installed pwsh-preview. It failed with an error: New-PSSession: Basic authentication is not supported over HTTP on Unix.

Kais-Mac-Pro:~ kai$ pwsh-preview 
PowerShell v6.1.0-preview.3
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.

PS /Users/kai> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.1.0-preview.3
PSEdition                      Core
GitCommitId                    v6.1.0-preview.3
OS                             Darwin 17.6.0 Darwin Kernel Version 17.6.0: Tue May  8 15:22:16 PDT 2018; root:xnu-4570.61.1~1/RELEASE_X86_64
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0


PS /Users/kai> $UserCredential = Get-Credential

PowerShell credential request
Enter your credentials.
User: [email protected]
Password for user [email protected]: ***********

PS /Users/kai> $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
New-PSSession : Basic authentication is not supported over HTTP on Unix.
At line:1 char:12
+ $Session = New-PSSession -ConfigurationName Microsoft.Exchange -Conne ...
+            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ResourceUnavailable: (:) [New-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : System.Management.Automation.Remoting.PSRemotingDataStructureException,Microsoft.PowerShell.Commands.NewPSSessionCommand

PS /Users/kai> 

As I see it (which may or may not be correct), one of the primary use cases for PowerShell on non-Windows systems is for administering remote Windows systems, including Azure and Office 365.

The number of systems administrators that will be deploying and using PowerShell to administer their local macOS or Linux systems will likely be quite low.

Can we please have test added to the suite of tests that you're currently running for each build to verify that PowerShell can connect to a remote system, such as Office 365?

I will log this as a separate feature request.

Thanks, and I do appreciate the hard work you're putting in to make this something that will work well across a number of wildly different platforms. I'm sure it's not easy!

@kai-h Yes, it is not easy. Currently we haven't remoting tests. @JamesWTruher announced this work a long time ago but I do not know if there is any progress.

Do we know when this will be resolved? Currently unable to connect to Office 365: "New-PSSession : Basic authentication is not supported over HTTP on Unix."

Is there a workaround?

@kai-h @echobb8 See #6890
I guess we get this public in next preview4.

The fix is in 6.1.0 RC1.

Same issue. My workaround was to run PowerShell through Docker https://hub.docker.com/r/microsoft/powershell/

* Updated using 6.1.1 GA *
I just tested in WSL-Ubuntu with PowerShell Core 6.1.1 GA. It's working!
Just in case, I'm using the latest version of the Module too:

Sample Script:

$MyUserName = "[email protected]";
$MyPassword = ConvertTo-SecureString '12$passw299!' -asplaintext -force;
$MyCred = [System.Management.Automation.PSCredential]::new($MyUserName, $MyPassword)

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

Woohoo!!

wslubuntu1804_o365_2018-12-17_16-55-30

Seems I am running into this issue today, after having successfully remoted into Exchange Online multiple times last week. Running macOS 10.14.2.

PS /Users/charles> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.1.1
PSEdition                      Core
GitCommitId                    6.1.1
OS                             Darwin 18.2.0 Darwin Kernel Version 18.2.0: M...
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

@craysiii

I got MAC OS X
ProductVersion: 10.13.6

Tested 6.1.1 GA and works OK.

I suggest to post the error you are getting and a sample code to reproduce the issue.

off365_611ga_2018-12-17_16-38-22

I ran into this issue because I was using the (old?) URL of:

https://ps.outlook.com/powershell/

Simply changing the URL to:

https://outlook.office365.com/powershell-liveid

fixed authentication issues for me.

Was this page helpful?
0 / 5 - 0 ratings