Ryan MacPhee
Ryan MacPhee

Reputation: 73

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.

https://learn.microsoft.com/en-us/powershell/exchange/connect-to-exchange-online-powershell?view=exchange-ps

Upvotes: 1

Views: 15678

Answers (1)

James Burney
James Burney

Reputation: 76

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

I used: winrm quickconfig

https://learn.microsoft.com/en-us/windows/win32/winrm/installation-and-configuration-for-windows-remote-management#quick-default-configuration

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

https://social.technet.microsoft.com/Forums/en-US/b514abea-ab42-429d-bce5-a96274868927/winrm-basic-authentication-is-currently-disabled-quotallowbasicquotdword00000001

After that I was able to connect without that error.

Upvotes: 6

Related Questions