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.
Advertisеment
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.
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.
- Open PowerShell as Administrator. Tip: You can add "Open PowerShell As Administrator" context menu.
- 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. - 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. - 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. - 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. - Finally, to remove a user account, execute the command
Remove-LocalUser -Name "user_name"
. 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
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:
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!
Advertisеment
omg thank you so much!! it worked❤️