title: Create Powershell Session is failed using OAuth
body: <p>Trying to change a script from basic authentication to Exchange Online V2 Module to utilise Modern Auth.</p>
  <pre><code>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
  
  </code></pre>
  <p>The Error im getting is</p>
  <blockquote>
  <p>New-ExoPSSession : Create Powershell Session is failed using OAuth</p>
  </blockquote>
  <p>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</p>
  <p>I've mainly used this a source, but have looked around in different places to find the answer but no luck.</p>
  <blockquote>
  <p>https://docs.microsoft.com/en-us/powershell/exchange/connect-to-exchange-online-powershell?view=exchange-ps</p>
  </blockquote>