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)
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 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