I have a Windows 10 computer where I created a local user account used by multiple people.
Occasionally, users sign in with their Microsoft accounts, and these accounts remain signed in. I can see the Microsoft account on top in the Settings app, but it is still listed as a local account in the Control Panel.
How can I accurately detect if the current user is signed in with a Microsoft account using PowerShell?
I tried this already:
(Get-LocalUser User).PrincipalSource
Get-WmiObject Win32_UserAccount -Filter "SID=$sid" | Select-Expand AccountType
Get-WmiObject Win32_UserAccount | Where-Object { $_.LocalAccount -eq $true }
All these commands return that the account is a local account, but in fact in the setting app on top I see a Microsoft account signed in.