By default, Windows PowerShell Remote Access is disabled in Windows 7 SP1, so you will get the below error while trying to connect Exchange Online via PowerShell
PS C:\Windows\system32> $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
[outlook.office365.com] Connecting to remote server failed with the following error message : The WinRM client received an HTTP bad request status (400), but the remote service did not include any other information about the cause of the failure. For more information, see the about_Remote_Troubleshooting Help topic.
+ CategoryInfo : OpenError: (System.Manageme….RemoteRunspace:RemoteRunspace) , PSRemotingTransportException
+ FullyQualifiedErrorId : PSSessionOpenFailed
To resolve this issue, open PowerShell with ‘Run as Administrator’ privilege
1. Check winrm status by Get-service winrm
2. If status of winrm is stopped (needs to be running), execute enable-PSremoting -force
You can achieve the same result by opening services.msc and starting the service – ‘Windows Remote Management (WS-Management)’
Note: Even if you still receive the same error after enabling WinRM, then you are probably typing domain\username instead of firstname.lastname@example.org in the credentials window popup screen.