Create Powershell Session Is Failed Using Oauth

Create Powershell Session Is Failed Using Oauth

Trying to change a script from basic authentication to Exchange Online V2 Module to utilise Modern Auth.

Install-Module PowershellGet -Force
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

# Install and test
Install-Module -Name ExchangeOnlineManagement

Get-Module ExchangeOnlineManagement -ListAvailable

$UserCredential = Get-Credential

Connect-ExchangeOnline -Credential $UserCredential -ShowProgress $true

The Error im getting is

New-ExoPSSession : Create Powershell Session is failed using OAuth

I've tried removing and reinstalling the module, Which didn't work I've tried this script on a different machine, Which worked I've tried setting the proxy parameters to null, Which didn't work I've tried using the code on the microsoft doc to only utilise modern auth and not Two factor, Didnt work

I've mainly used this a source, but have looked around in different places to find the answer but no luck.

1 Answer

I had the same thing happen to me. I had to enable winrm.

I used: winrm quickconfig

Then I had to enable basic auth for WinRM [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WinRM\Client] "AllowBasic"=dword:00000001

After that I was able to connect without that error.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

David Miller
Author

David Miller

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.