In this tutorial, I will explain how to create local user accounts in Windows using PowerShell. PowerShell provides a quick and easy way to automate the process of creating new users. I recently needed to set up several new employee accounts on Windows PCs in our office, so I used PowerShell to speed things up.
Note: I used Windows PowerShell ISE to execute all the PowerShell scripts.
Create a New Local User with New-LocalUser in PowerShell
The simplest way to create a new local user in Windows in PowerShell is with the New-LocalUser cmdlet. Here’s an example of creating a new user named “John Smith”:
New-LocalUser -Name "John Smith" -Description "Sales Associate" -NoPasswordThis creates a new local user account named “John Smith” with the description “Sales Associate”. The -NoPassword switch specifies that no password is required for the account initially.
You can also specify a password for the new account:
$Password = Read-Host -AsSecureString
New-LocalUser -Name "Amy Johnson" -Password $Password -FullName "Amy Johnson" -Description "Marketing Manager"In this example, we first prompt for the password using Read-Host and store it as a secure string in the $Password variable. Then we provide the password when calling New-LocalUser along with the full name and description for the account.
Check out Create Desktop Shortcuts with Custom Icons Using PowerShell
Add a User to a Local Group using PowerShell
When you create a new local user, you may want to add them to an existing local group to grant the appropriate permissions. You can do this with the Add-LocalGroupMember cmdlet:
Add-LocalGroupMember -Group "Users" -Member "John Smith"This adds the local user “John Smith” to the local “Users” group.
Modify Local User Properties in PowerShell
After creating a local user, you can modify properties like the full name, description, password, and more using the Set-LocalUser cmdlet. For example:
Set-LocalUser -Name "John Smith" -FullName "John W. Smith" -Description "Sales Lead" This updates the full name and description for the user “John Smith”.
To change the password for a local user:
$NewPassword = Read-Host -AsSecureString
Set-LocalUser -Name "Amy Johnson" -Password $NewPasswordThis prompts for a new password and updates the password for the user “Amy Johnson”.
Check out Create a Self-Signed Certificate Using PowerShell
Check if a Local User Exists in PowerShell
Before attempting to create a new local user, you may want to check if a user with that username already exists to avoid an error. Here’s an example and the complete PowerShell script:
$UserName = "John Smith"
if (Get-LocalUser | Where-Object {$_.Name -eq $UserName}) {
Write-Host "The user $UserName already exists."
} else {
Write-Host "The user $UserName does not exist."
New-LocalUser -Name $UserName -NoPassword
}This script checks if a local user named “John Smith” exists. If so, it outputs a message saying the user already exists. If not, it creates the new user.
Here is the exact output in the screenshot below:

Remove a Local User using PowerShell
To remove a local user account that is no longer needed, use the Remove-LocalUser cmdlet in PowerShell:
Remove-LocalUser -Name "Amy Johnson"This deletes the local user account named “Amy Johnson”. Note that you cannot remove an account that is currently logged in.
Conclusion
PowerShell provides a variety of cmdlets for managing local users in Windows. You can easily create new users, modify user properties, add users to groups, check if users exist, and remove users as needed. Using PowerShell to automate these tasks can save a lot of time compared to using the GUI, especially when you need to create multiple accounts.
The key cmdlets to remember are:
New-LocalUser– Create a new local user accountSet-LocalUser– Modify properties of a local userAdd-LocalGroupMember– Add a user to a local groupGet-LocalUser– List local users and check if a user existsRemove-LocalUser– Delete a local user account
I hope this tutorial helps you understand how to create and manage local Windows users with PowerShell. Let me know if you have any other questions in the comment below:
You may also like:
- Create a Local Admin Account Using PowerShell
- Retrieve Your Windows Product Key Using PowerShell
- Enable WinRM (Windows Remote Management) Using PowerShell
Bijay Kumar is an esteemed author and the mind behind PowerShellFAQs.com, where he shares his extensive knowledge and expertise in PowerShell, with a particular focus on SharePoint projects. Recognized for his contributions to the tech community, Bijay has been honored with the prestigious Microsoft MVP award. With over 15 years of experience in the software industry, he has a rich professional background, having worked with industry giants such as HP and TCS. His insights and guidance have made him a respected figure in the world of software development and administration. Read more.