When connecting to Exchange Online PowerShell Module v2 using an administrator account, you may get an error message: New-ExoPSSession: Create PowerShell Session failed using OAuth.
Error Details:
New-ExoPSSession : Create Powershell Session is failed using OAuth At C:\Program Files\WindowsPowerShell\Modules\ExchangeOnlineManagement\2.0.5\netFramework\ExchangeOnlineManagement.psm1:475 char:30 … PSSession = New-ExoPSSession -ExchangeEnvironmentName $ExchangeEnviro … FullyQualifiedErrorId : System.Exception,Microsoft.Exchange.Management.ExoPowershellSnapin.NewExoPSSession |
Connect-ExchangeOnline
Connect-ExchangeOnline -UserPrincipalName <Administrator User Account>
Fix for PowerShell session is failed using OAuth
To fix this issue, you need to update the registry setting, use AllowBasic, and try again. Let’s see which registry key needs to be updated and then test it again.
Open Registry Editor on your Windows 10 or Windows 11 PC using administrator privileges, find the Registry key: HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WinRM\Client and set its value to 1.
Let’s try again to see if it works fine this time. As you can see, no errors were reported, and the command was executed successfully.
Next, try Get-Mailbox
command to confirm that you are getting the results.