powershell unable to connect to O365

James Chan 56 Reputation points
2022-12-05T21:41:39.863+00:00

Hi,

I use PowerShell to connect to O365 as MS doc (https://learn.microsoft.com/en-us/powershell/exchange/connect-to-exchange-servers-using-remote-powershell?view=exchange-ps) shows.
It's all pass and also pop up a credential window ask my login; I use my global admin account (exchange admin role as well) and pass too.

but I got the error when I run the last command ($Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://<ServerFQDN>/PowerShell/ -Authentication Kerberos -Credential $UserCredential).

thanks,

267385-powershell-unable-to-connect-to-o365-1.png

Exchange | Exchange Server | Management
Exchange | Exchange Server | Management
The administration and maintenance of Microsoft Exchange Server to ensure secure, reliable, and efficient email and collaboration services across an organization.
Windows for business | Windows Server | User experience | PowerShell
{count} votes

Answer accepted by question author
  1. KyleXu-MSFT 26,396 Reputation points
    2022-12-06T07:44:16.637+00:00

    @James Chan

    Here is the version for connecting to Exchange online: Connect to Exchange Online PowerShell (Please note, basic is disabled for Exchange online, you need to enable basic for remote PowerShell first)

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

    If you don't want to enable basic for Exchange online, you will need to connect to Exchange with modern auth.

    Import-Module ExchangeOnlineManagement  
    Connect-ExchangeOnline -UserPrincipalName <UPN>  
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    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.


    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Andy David - MVP 159.7K Reputation points MVP Volunteer Moderator
    2022-12-05T22:54:06.207+00:00
    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.