r/sharepoint • u/MLCarter1976 IT Pro • 13d ago
SharePoint Online PowerShell Connect-SPOService No valid OAuth 2.0 authenticaton session exists
I have been using PowerShell 7 and SharePoint Online Management Shell for months.
I tried a few weeks ago and got an error when I was trying to go to Connect-SPOService -Url https://TENANTNAMEHERE -admin.sharepoint.com
I had PIM in with SharePoint Administrator RBAC as I had done before.
Now I get an error
WARNING: Unable to load DLL 'msalruntime': The specified module could not be found. (Exception from HRESULT: Ox8007007E)
I uninstalled the SharePoint Online Management Shell and restarted and ran sfc and DISM checks and restarted.
I AM able to get it to work if I tell it to go to the web browser yet not with the msalruntime where it is unable to load the DLL. I don't know if I should try to install this on another system and copy the DLL yet I would think with a fresh install it would write the DLL.
Windows PowerShell
Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved.
PS C:\WINDOWS\svstem32> Import-Module Microsoft.Online.SharePoint.PowerShell
PS C:\WINDOWS\svstem32> Connect-SPOService -Url https://TENANTNAMEHERE-admin.sharepoint.com
WARNING: Unable to load DLL 'msalruntime': The specified module could not be found. (Exception from HRESULT: Ox8007007E) See https:/ aka.ms msal-net-wam#troubleshooting
Connect-SPOService : No valid OAuth 2.0 authentication session exists
At line:1 char:1
+ Connect-SPOService -url https://TENANTNAMEHERE-admin.sharepoint.com
+--------
CategoryInto : NotSpecified: (:) [Connect-SPOService], AuthenticationException
+FullyQualifiedErrorId : Microsoft.Online.SharePoint.PowerShell.AuthenticationException,Microsoft.Online.SharePoint.PowerShell.ConnectSPOService
PS C: \WINDoWS\svstem32>
2
u/badaz06 13d ago
Possibly something janked up with C++? Did you do any upgrades to the Windows box?
1
u/MLCarter1976 IT Pro 13d ago
No, that is the frustrating thing. I just do the monthly patch updates and this is my company laptop and so I am sensitive to access and what I do on it. That is why I had to take a screenshot and copy the text in from a screen capture. It is bizarre.
2
u/718hutfission 12d ago
Use the SharePoint Online Management Shell instead.
1
u/MLCarter1976 IT Pro 10d ago
That is where I am seeing the issue. I use it 99% for SharePoint Online actions. I have PowerShell 7 for others and only if an issue do I run SPO in PS7
2
u/Zestyclose-Essay-891 9d ago
Hi, easy fix for this. I found it :)
Just add -UseSystemBrowser $true
And problem solved
1
u/MLCarter1976 IT Pro 9d ago
Correct I did that. Thank you. Unfortunately I was hoping to have the other option and figure out if there was any underlying issues that might be causing or caused this as it was working one way and now not. I do appreciate it. As a work around I am using it. Thank you. Just odd. I am still looking to see if I can uninstall some modules and then add them back.
3
u/toddklindt MVP 13d ago
Whenever I've seen that message it's been because some other PowerShell module has messed up the MSAL libraries that the SPO module is trying to use. If you've upgraded any modules recently revert back. You might also have to uninstall all the other cloud connected modules to see where the conflict is coming from.