Determine if current user account is Microsoft account?

How would I check in PS session if current user is an online account?
An online Windows account is when you use MS account to log into computer (opposite of that is local or offline account)

Start here

Get-LocalUser (Microsoft.PowerShell.LocalAccounts) - PowerShell | Microsoft Learn

1 Like

Thank you, Get-LocalUser however lists all local accounts, but in the mean time I’ve figured out following works for current user only:

[System.Security.Principal.WindowsIdentity]::GetCurrent().AuthenticationType -eq "CloudAP"

Yes, it does list the local users, but the documentation indicates it also lists the Microsoft accounts

From the documentation

Get-LocalUser -Name "MicrosoftAccount\username@Outlook.com"

Name                                    Enabled  Description
----                                    -------  -----------
MicrosoftAccount\username@outlook.com  True     Description of this account.

If you can do that, then Get-LocalUser is the easy way. But what if you are trying to find out which accounts not local because you don’t know which aren’t, and thus would not know what to put after MicrosoftAccount\ the following would let you know.

Get-LocalUser |  Select-Object name,PrincipalSource

Any with PrincipalSource = MicrosoftAccount would be a Microsoft account, and a value of Local would be local account.

For anyone to lazy to look :slight_smile: These are the available Principal Sources

Local
Active Directory
Azure Active Directory group
Microsoft Account

Lol that’s odd. Why would a user be a group