Menu
Modern Workplace Blog
  • Home
  • About: Kenneth van Surksum
  • Cookie Policy
Modern Workplace Blog
March 11, 2021November 27, 2022

Create Powershell Session is failed using OAuth when using the Exchange Online V2 PowerShell module

Update: Since September 2022, the v3.0 PowerShell module of Exchange Online is available, which when used solves this issue as well. You can update your existing PowerShell module by running the following command.

Update-Module -Name ExchangeOnlineManagement 

Today, while wanting to check some settings in our Exchange Online environment, I ran into an issue where the New-ExoPSSession command let failed with the following error: Create Powershell Session is failed using OAuth. It took me some time to figure out what was causing this issue, and I’m documenting it here for future reference.

TL;DR; – The solution was to modify the set the MDM Security Baseline in Microsoft Endpoint Manager and set the “Client basic authentication” setting under Remote Management to “Not Configured”

Some more details below,

While wanting to start a PowerShell session to Exchange Online using the Exchange Online PowerShell V2 module (EXO V2), I ran into the issue that after providing my Userid, password and approve with the MFA request, I was presented with the following error: New-ExoPSSession : Create Powershell Session is failed using OAuth.

Error when connecting to Exchange Online

After some searches on the internet I ended up at the Prerequisites for the EXO V2 module, which describes the following:

WinRM needs to allow Basic authentication (it’s enabled by default). We don’t send the username and password combination, but the Basic authentication header is required to send the session’s OAuth token, since the client-side WinRM implementation has no support for OAuth.

Wait, what? – so the module doesn’t use basic authentication (userid/password) but requires it to be enabled.

I quickly checked the configuration using the following command: winrm get winrm/config/client/auth

Basic auth disabled

Based on the documentation I tried to update the setting Basic to true, but that failed because the setting was coming from a GPO. But wait a minute, my machine in Azure AD joined, and I’m not using GPO technology.

I am doing some security configuration though on my Modern Workplace, and the first place to start is the Security Baseline, I quickly found the following setting, Client basic authentication which is set to “Disabled” by default.

MDM Security Baseline for Windows 10

After modifying this setting to “Not configured” and syncing the policy using the Company portal I got another result when requesting the WinRM settings.

WinRM basic authentication enabled

With this setting now set to basic, I tried again to connect to Exchange Online, this time with an expected result.

Succesful connection to Exchange Online using PowerShell

Conclusion

This article serves as a note for myself in case I drop into this issue again in the future, and hopefully it helped you if you ran into this issue and found my blogpost.

Be careful though when implementing exceptions for the baseline, especially in large environments this might be a reason to create a different baseline for people administering the environment and not giving this exception to all your users. Even better would be to not let administrators perform these tasks from their own workstations but require the usage of Privileged Access Workstations. I’m realistic though, and consider that scenario Utopia for many environments today.

Tweet
Follow me
Tweet #WPNinjasNL

9 thoughts on “Create Powershell Session is failed using OAuth when using the Exchange Online V2 PowerShell module”

  1. Roel Heymans says:
    March 11, 2021 at 4:08 pm

    Bumped into this one a couple of weeks ago.
    Will Microsoft ever stop asking us to break security each time they are slow in removing legacy?

    Reply
  2. Pingback: Modern Workspace: PowerShell OAuth Error – PwnDefend
  3. Sam Masiello says:
    June 9, 2021 at 5:12 pm

    I have also updated the following registry key. It gets changed back via the GPO/Microsoft Endpoint Manager policy, but at least gives me the ability to do what I need to do without changing a setting within the global security baseline

    HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WinRM\Client] “AllowBasic”=dword:00000001

    Reply
    1. Seif says:
      September 1, 2021 at 5:06 pm

      Thank you. This worked for me.

      Reply
  4. Santos L Halper says:
    June 15, 2021 at 5:18 pm

    Very helpful indeed, thank you for sharing this my friend!

    Reply
  5. Craig Reitano says:
    July 6, 2021 at 1:02 am

    Very helpful! thank you.

    Reply
  6. Liam O'Brien says:
    February 19, 2022 at 9:57 pm

    Thanks a lot! Got me past this nagging problem.

    Reply
  7. Jon says:
    May 31, 2022 at 3:57 am

    Added these lines to write the registry before I connect to Exchange Online

    #Connect to Exchange Online
    if((Test-Path -LiteralPath “HKLM:\SOFTWARE\Policies\Microsoft\Windows\WinRM\Client”) -ne $true) { New-Item “HKLM:\SOFTWARE\Policies\Microsoft\Windows\WinRM\Client” -force -ea SilentlyContinue };
    New-ItemProperty -LiteralPath ‘HKLM:\SOFTWARE\Policies\Microsoft\Windows\WinRM\Client’ -Name ‘AllowBasic’ -Value 1 -PropertyType DWord -Force -ea SilentlyContinue;
    Set-ExecutionPolicy RemoteSigned
    Install-Module -Name ExchangeOnlineManagement
    Connect-ExchangeOnline

    Reply
  8. Burt says:
    July 18, 2022 at 8:32 pm

    =============================================================

    New update available!
    You are using an older version of Exchange PowerShell cmdlets which may be using (soon to be deprecated) Basic authentication.
    Please install version 2.0.6 of the ExchangeOnlineManagement module to upgrade to the latest version of cmdlets, which are REST based, more secure, reliant and performant than the remote PowerShell cmdlets that you are currently using.

    For more information on the latest cmdlets released, visit: https://techcommunity.microsoft.com/t5/exchange-team-blog/exchange-online-powershell-v2-module-preview-now-more-secure/ba-p/2922946
    To download the latest version of the module, visit https://www.powershellgallery.com/packages/ExchangeOnlineManagement/2.0.6-Preview5

    ============================================================

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Founding member of:

Recent Posts

  • MAM vs. MDM: Choosing the Right Mobile Management Approach
  • Comparing Web Filtering and Security: Microsoft Entra Internet Access (Global Secure Access) vs. Microsoft Defender for Endpoint (MDE)
  • Navigating New Authentication Methods: SMS for Password Reset, Not for MFA
  • From SPF to DANE: Securing Microsoft 365 Email Communications
  • Protecting your Break Glass accounts in Entra now that MFA gets enforced on more and more Admin portals

Books

System Center 2012 Service Manager Unleashed
Amazon
System Center 2012 R2 Configuration Manager Unleashed: Supplement to System Center 2012 Configuration Manager
Amazon
System Center Configuration Manager Current Branch Unleashed
Amazon
Mastering Windows 7 Deployment
Amazon
System Center 2012 Configuration Manager (SCCM) Unleashed
Amazon

Archives

  • February 2025
  • January 2025
  • September 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • September 2023
  • August 2023
  • February 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • May 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • August 2019
  • July 2019
  • November 2016
  • November 2015
  • June 2015
  • May 2015
  • November 2014
  • July 2014
  • April 2014
  • March 2014
  • February 2014
  • January 2014
  • November 2013
  • August 2013
  • April 2013
  • March 2013
  • January 2013
  • December 2012
  • November 2012
  • August 2012
  • July 2012
  • June 2012

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Categories

  • ABM (4)
  • Advanced Threat Protection (4)
  • Announcement (44)
  • Azure (3)
  • AzureAD (73)
  • Certification (2)
  • Cloud App Security (5)
  • Conditional Access (58)
  • Configuration Manager (24)
  • Entra (2)
  • Entra Id (8)
  • Events (14)
  • Exchange Online (9)
  • Identity Protection (5)
  • Intune (27)
  • Licensing (2)
  • Microsoft Defender (1)
  • Microsoft Defender for Endpoint (1)
  • Microsoft Endpoint Manager (35)
  • Mobile Application Management (4)
  • Modern Workplace (74)
  • Office 365 (10)
  • Overview (11)
  • Power Platform (1)
  • PowerShell (2)
  • Presentations (9)
  • Privileged Identity Management (5)
  • Role Based Access Control (2)
  • Security (63)
  • Service Manager (4)
  • Speaking (30)
  • Troubleshooting (4)
  • Uncategorized (11)
  • Windows 10 (15)
  • Windows 11 (5)
  • Windows Update for Business (4)
  • WMUG.nl (16)
  • WPNinjasNL (32)

Tags

#ABM #AzureAD #community #conditionalaccess #ConfigMgr #IAM #Intune #m365 #MEM #MEMCM #microsoft365 #modernworkplace #office365 #security #webinar #wmug_nl ATP authentication strength AzureAD Branding Community Conditional Access ConfigMgr ConfigMgr 2012 Email EXO Identity Intune Licensing M365 MCAS MFA Modern Workplace Office 365 OSD PIM Policy Sets Presentation RBAC roles Security System Center Task Sequence troubleshooting webinar

Recent Comments

  • brc on Protecting your Break Glass accounts in Entra now that MFA gets enforced on more and more Admin portals
  • [m365weekly] #186 – M365 Weekly Newsletter on MAM vs. MDM: Choosing the Right Mobile Management Approach
  • Dean Gross on Comparing Web Filtering and Security: Microsoft Entra Internet Access (Global Secure Access) vs. Microsoft Defender for Endpoint (MDE)
  • nikhil tech on Protecting your Break Glass accounts in Entra now that MFA gets enforced on more and more Admin portals
  • Kenneth on Comparing Web Filtering and Security: Microsoft Entra Internet Access (Global Secure Access) vs. Microsoft Defender for Endpoint (MDE)

This information is provided “AS IS” with no warranties, confers no rights and is not supported by the author.

Copyright © 2021 by Kenneth van Surksum. All rights reserved. No part of the information on this web site may be reproduced or posted in any form or by any means without the prior written permission of the publisher.

Shorthand: Don’t pass off my work as yours, it’s not nice.

©2025 Modern Workplace Blog | Powered by WordPress and Superb Themes!
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Cookie settingsACCEPT
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these cookies, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT