BUG: new-localuser fails to allow connection to Microsoft account
The New-LocalUser cmdlet available in Windows 10 Anniversary Update cannot perform a function described in the documentation.
Local user accounts may be connected with existing Microsoft accounts. New-LocalUser should support this by accepting a -Name parameter of the form "MicrosoftAccount<user>@outlook.com". This is described in the detailed help.
However this fails because the parameter fails validation as it is over 20 characters in length (already true with "MicrosoftAccount" and "@outlook.com" let alone the "actual" user name). The 20 character limit is valid for a regular local account name, but shouldn't be valid for an MS account name.
There appears no other way I can find to create a local user account with an existing MS account; so this is rather major.
Note that also the error message from the "problematic" call is also of spurious grammar (where it inserts the length of the name parameter provided):
PS C:\WINDOWS\system32> New-LocalUser -name 'MicrosoftAccount<a rel="nofollow noreferrer" href="mailto:email@example.com">firstname.lastname@example.org'
New-LocalUser : Cannot validate argument on parameter 'Name'. The character length of the 31 argument is too long. Shor
ten the character length of the argument so it is fewer than or equal to "20" characters, and then try the command agai
At line:1 char:21
+ New-LocalUser -name 'MicrosoftAccount<a rel="nofollow noreferrer" href="mailto:email@example.com">firstname.lastname@example.org'
+ CategoryInfo : InvalidData: (:) [New-LocalUser], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.NewLocalUserCommand
Luc FULLENWARTH commented
Still same bug with Windows 10 1909
I opened a Github issue here: https://github.com/PowerShell/PowerShell/issues/12261
+1 as well. Need to script deletion of Microsoft account and can't do it with native PowerShell cmdlet. Please update the documentation at least to stop us wasting our time.
+1 For still an issue in 2019...
Just realized this :) still issue in 2018