What are the PowerShell command syntax that could be used to create a new user?

Although the concept of multiple users sharing one device or one PC is getting rarer by the day, there are still cases when you have to share PCs. In such a situation, it is useful to have multiple user accounts on a single PC. Recently, we saw how to create a new user account in Windows 10. Sometimes it can be useful to create a user account with PowerShell. Here is how it can be done.

Advertisement

In modern Windows versions, you usually have a number of system accounts for various services and internal Windows tasks, plus a hidden Administrator account and your personal account. If you need to share your PC with family members or other people, it is a good idea to create a dedicated user account for each person. This increases security and privacy of the OS and allows you to keep your sensitive data private and your settings personalized to your taste.

PowerShell is an advanced form of command prompt. It is extended with a huge set of ready-to-use cmdlets and comes with the ability to use .NET framework/C# in various scenarios.

What are the PowerShell command syntax that could be used to create a new user?

Here is how to use it to create a new user account. Before proceeding, ensure that your user account has administrative privileges.

We will use a special cmdlet, New-LocalUser. The New-LocalUser cmdlet creates a local user account. This cmdlet creates a local user account or a local user account that is connected to a Microsoft account.

To create a User Account in Windows 10 with PowerShell, do the following.

  1. Open PowerShell as Administrator. Tip: You can add "Open PowerShell As Administrator" context menu.
  2. To create a new user account without a password, type New-LocalUser -Name "user_name" -Description "Description of your new account." -NoPassword. Substitute the 'user_name' portion with the actual user name. Also, provide some meaningful description for it.
    What are the PowerShell command syntax that could be used to create a new user?
    What are the PowerShell command syntax that could be used to create a new user?
  3. To create a user account that has a password, firstly execute the following line: $Password = Read-Host -AsSecureString. Type in your PowerShell console the desired password. It will be processed  by the Read-Host cmdlet and will be stored in the $Password variable.
    What are the PowerShell command syntax that could be used to create a new user?
    What are the PowerShell command syntax that could be used to create a new user?
  4. Now, run the command New-LocalUser "user_name" -Password $Password -FullName "full_user_name" -Description "Description of the account". Substitute the 'user_name', 'full_user_name' with the actual values. Also, provide some meaningful description for your new user account.
    What are the PowerShell command syntax that could be used to create a new user?
    What are the PowerShell command syntax that could be used to create a new user?
  5. The next command can be used to add your user to a local group. Add-LocalGroupMember -Group "Administrators" -Member "user_name". Instead of 'Administrators', you can use any available local group according to what you want.  Replace the 'user_name' portion with the actual user name.
    What are the PowerShell command syntax that could be used to create a new user?
    What are the PowerShell command syntax that could be used to create a new user?
  6. Finally, to remove a user account, execute the command Remove-LocalUser -Name "user_name".
    What are the PowerShell command syntax that could be used to create a new user?
    What are the PowerShell command syntax that could be used to create a new user?
      Replace the 'user_name' portion with the actual user name.

That's it.

Articles of interest:

  • Create Shortcut to Run a PS1 PowerShell File in Windows 10
  • Generate QR Code with PowerShell in Windows 10
  • Find Your Windows Upgrade History with PowerShell
  • Create Windows 10 Bootable USB Stick With PowerShell
  • Get amount of words, chars and lines in a file using PowerShell
  • Add PowerShell As Administrator Context Menu in Windows 10
  • Add PowerShell file (*.ps1) to New Context Menu of File Explorer
  • Get File Hash With PowerShell in Windows 10
  • How To Restart Computer with PowerShell
  • Start a Process Elevated from PowerShell

RECOMMENDED: Click here to fix Windows issues and optimize system performance

Support us

Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:

What are the PowerShell command syntax that could be used to create a new user?
What are the PowerShell command syntax that could be used to create a new user?

If you like this article, please share it using the buttons below. It won't take a lot from you, but it will help us grow. Thanks for your support!

Advertisment

Author: Sergey Tkachenko

Sergey Tkachenko is a software developer who started Winaero back in 2011. On this blog, Sergey is writing about everything connected to Microsoft, Windows and popular software. Follow him on Telegram, Twitter, and YouTube. View all posts by Sergey Tkachenko