0
votes

I would like to connect to outlook office 365 by using PowerShell.

Following below steps performed -

1)

   PS C:\Windows\system32> $UserCredential = Get-Credential

2)

   PS C:\Users> $s = New-PSSession -URI https://outlook.office365.com/PowerShell -Credential $UserCredential -AllowRedirection

Result / Output get error -

New-PSSession : [outlook.office365.com] Connecting to remote server outlook.office365.com failed with the following error message : [ClientAccessServer=MA1PR0101CA0048,BackEndServer=,RequestId=6d22e2da-f0c9-4880-9936-1a3c12c1097b,TimeStamp=9/23/2019 2:01:34 PM] Access Denied For more information, see the about_Remote_Troubleshooting Help topic. At line:1 char:6 + $s = New-PSSession -URI https://outlook.office365.com/PowerShell -Cre ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotingTransportExcep tion + FullyQualifiedErrorId : -2144108477,PSSessionOpenFailed

2
Do you have 2fa on your account enabled? If you do, you either need to create an app password for your account and use that as the password, or install the MFA module for connecting to Exchange Online.SteamerJ

2 Answers

0
votes

Try to open your Powershell IDE as administrator. Let me know how it works.

Cheers!

0
votes

Adding -Authentication Basic fixed this error for me. This is what Microsoft does in it's documentation, too.