jflieben / OnedriveMapperV5

Other
13 stars 2 forks source link

Script detecting an incorrect account and failing to connect. #6

Open jtciv opened 1 month ago

jtciv commented 1 month ago

I have a personal email as well as a shared login which uses the same domain. When the script runs, it pulls the shared login(which does not have access to the sharepoint), attempts to connect for around a minute, and then fails.

Pasted the lines I believe to be relevant from the log below, please let me know if further information may help. Actions I've taken so far to resolve include signing out of the shared account, resetting Edge, removing the account from my list in settings, and clearing credential manager. Despite this, the script still seems to grab that shared account from an unknown location.

Would it be possible to force it to ignore certain addresses, or provide the one that it should prioritize?

08/13/2024 10:46:29 | INFO | Attempting to detect username at https://www.microsoft365.com/?from=PortalHome, waited for 2 seconds 08/13/2024 10:46:38 | INFO | You're already logged in! No need to display login dialog 08/13/2024 10:46:40 | INFO | Attempting to detect username at https://[my domain]-my.sharepoint.com/PersonImmersive.aspx?accountname=i:0#.f|membership|sharedemailaccount@mydomain.com&sw=auth, waited for 4 seconds 08/13/2024 10:46:42 | INFO | You're already logged in! No need to display login dialog etc... etc... 08/13/2024 10:48:47 | ERROR | Failed to get the username from the URL for over 62 seconds while at https://[my domain]-my.sharepoint.com/PersonImmersive.aspx?accountname=i:0#.f|membership|sharedemailaccount@mydomain.com&sw=auth, aborting

As a sidenote, this behavior started today, previously it loaded the correct account. I'm not sure what may have changed, as I hadn't done anything other than turn on the PC.

jflieben commented 1 month ago

@jtciv which version are you using? V5? I've seen this before when this was set as the sync/org account in the Edge browser. Changing that to the personal one fixed it for that customer.

jtciv commented 1 month ago

Yes, V5 of the script. I tried doing as you suggested and made sure I was signed into my personal account in Edge, but still seem to be having the same issue. Please let me know if there are any additional logs or info I can send over that might be of help, I'm stumped about where it's even finding the shared account anymore. To me, it appears fully removed.

jflieben commented 1 month ago

ah, I remember another case now. OnedriveMapper uses a separate instance of Edge (profile), in %appdata%. This profile probably has your shared account configured. It could even be that that gets auto configured because of some policy/local setting (onedrivemapper does not manage accounts directly).

So two things you can try: 1) wipe the local profile of onedrivemapper in %appdata%. Least likely to help, but simple to do. 2) run OnedriveMapper step by step and make the Edge browser window visible. When it is visible, use shortkeys to get into the menu (it won't show buttons as it is a Selenium instance) and remove your connected shared account from the profile there.

this is the part of the code you shouldn't run, to ensure the Edge Window is visible:

   #hide edge window, sometimes needs extra attempts
    $attempts = 0
    while($true){
        if($attempts -gt 5){break}
        try{
            $res = $global:cachedHwnds | % {[native.win]::ShowWindow($_,0)}
            break
        }catch{
            $attempts++
            Start-Sleep -s 1
        }
    }