0
1
According to the article Get-LocalUser, the syntax to get a Microsoft local account from PowerShell is:
Get-LocalUser -Name "MicrosoftAccount\myemail@outlook.com"
Except when I run this, I get the following error:
Get-LocalUser : User MicrosoftAccount\myemail@outlook.com was not found.
However, the account is definitely there. What am I missing here?
Later... I removed the account manually and then ran the following:
New-LocalUser -Name "MicrosoftAccount\myemail@outlook.com" -Description "Local account"
And then got this error message:
New-LocalUser : Cannot validate argument on parameter 'Name'. The character length of the 48 argument is too long. Shorten the character length of the argument so it is fewer than or equal to "20" characters, and then try the command again.
The actual email I'm using is reasonably long as it's of the form firstname.lastname-company@outlook.com - I wonder if there is an very old character limit in there somewhere from when local accounts were limited in length?
To restrict
Get-LocalUser
output toMicrosoftAccount
s useGet-LocalUser | Where-Object PrincipalSource -eq 'MicrosoftAccount'
The name for that Account here doesn't contain the email though. – LotPings – 2019-04-09T12:46:11.263