r/PowerShell • u/HourlySword • Mar 10 '26
Question Can't sign in to the ExchangeOnlineManagement module when launching PowerShell as admin
Hello everyone! Apologies in advance as i'm still a bit of a PowerShell novice! Been working on this issue for a while for someone and hoping it doesn't come to a full computer wipe. Basically they use the ExchangeOnlineManagement Module to sign in and manage many different tenants. Currently it DOES work if they try to login to an account using Connect-ExchangeOnline in powershell without admin rights. When they launch Powershell as admin and try doing the same thing, it gives the following error:
- "A specified logon session does not exist. It may already have been terminated."
- Error Code: 0xffffff80070520 / -2147023584
- Exception Type: MsalServiceException — OperationStopped
- Source: ExchangeOnlineManagement.psm1:591
Cross-checked their modules and there's a lot installed on their system that i don't have and they don't care if i have to remove them all or basically factory reset powershell to fix this (Mostly Az modules), so i was kinda hoping there was a way to just fully reset powershell/all modules to troubleshoot.
We've already tried the following:
- launch with powershell -noprofile and elevate
- installed latest PowerShell 7 and tried there
- checked for custom profiles under default user and admin accounts (didn't find any profiles set up)
- uninstalled ExchangeOnlineManagement and reinstalled latest version
Here's what I was going to try next:
- uninstalling all Az modules and other ones that don't come by default with Windows (grabbed a list from a clean installation)
- sfc /scannow + dism + windows repair install (feel like this won't really do anything but would be happy to hear otherwise lol)
- install EOM v3.4.0 temporarily and test with that
- clear out/.old the following folder: c:\users*username*\appdata\local\Microsoft\TokenBroker\Cache
- test on another windows profile (on the same pc)
Kinda banging my head against the wall, but i'm leaning towards this being an issue with an old/expired login token that EOM is trying to use.. just uncertain the best way to clear that out and weird that it only happens when launching as admin (doesn't matter which admin account/credentials we use)
Thank you so much in advance for any suggestions/advice here!