On Windows 10, you can create a local user account or an account connected to a Microsoft account to take advantage of additional benefits, such as settings syncing across devices and seamless integration to various Microsoft cloud services.
If you use Windows 10, you are likely already utilizing an account connected to a Microsoft account. However, if you need to set up another account (in addition to using the Settings app and Command Prompt), you can create a new local user account using PowerShell.
This guide will teach you the steps to create and delete a new local user account using PowerShell on Windows 10.
- Create new local user account with PowerShell
- Delete new local user account with PowerShell
Create new local user account with PowerShell
Use the following steps to create a standard or administrator local account with PowerShell:
Open Start on Windows 10.
Search for PowerShell, right-click the top result, and select the Run as administrator option.
Type the following command to temporarily store the password in a secure string inside the “$Password” variable and press Enter:
$Password = Read-Host -AsSecureString
Type the password for the new Windows 10 account and press Enter.
Type the following command to create the new account with PowerShell and press Enter:
New-LocalUser "NEW_ACCOUNT_NAME" -Password $Password -FullName "USER_FULL_NAME" -Description "DESCRIPTION"
In the command, change NEW_ACCOUNT_NAME for the account name and USER_FULL_NAME for the user’s full name. Also, replace DESCRIPTION with the description you want to use for the account.
Type the following command to add the Windows 10 account to the correct user group and press Enter:
Add-LocalGroupMember -Group "Administrators" -Member "NEW_ACCOUNT_NAME"
In the command, make sure to change NEW_ACCOUNT_NAME for the account name. In the above command, we add the new account to the Administrators group, which gives the user full access to the computer. However, if you want the user to have limited access, you can add the account to the Users group, making it a “Standard User.”
Once you complete the steps, the new account will be set up on the device with full access using administrative privileges. Of course, this is unless you added the account to the “Users” group, in which case the account will be a limited standard account.
Connect new account to a Microsoft account
Using PowerShell should also be possible to create a user account connected to a Microsoft account with this command:
New-LocalUser -Name "[email protected]" -Description "Microsoft account description". However, a bug still returns “New-LocalUser: Cannot validate argument on parameter ‘Name.’ The character length of the 36 arguments 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” message. As a result, the easiest way to get around this problem is to create a local account and then use the Settings app to link it with a Microsoft account.
To link a local account with a Microsoft account, use these steps:
Click on Accounts.
Click on Your Info.
Click the Sign in with your Microsoft account instead link.
Continue with the on-screen directions to connect your account to a Microsoft account.
After you complete the steps, the new account will be connected to the Microsoft account you specified.
Delete new local user account with PowerShell
Use the following steps to delete an account with PowerShell on Windows 10:
Search for Windows PowerShell, right-click the top result, and select the Run as administrator option.
Type the following command to delete the user account and press Enter:
Remove-LocalUser -Name "USER_ACCOUNT_NAME"
In the command, change USER_ACCOUNT_NAME with the account name you want to remove.
After you complete the steps, the account will be deleted from the computer. However, the user account data will remain. If you want to delete both account and data, the easiest way is to delete it is using the “Accounts” page from the Settings app.