The net user command in PowerShell is used to manage local user accounts on a Windows machine, allowing you to create new users, delete existing ones, and reset passwords. To use these commands, you must run PowerShell with Administrator privileges, as modifying user accounts is a system-level security action.
What You'll Need
- A computer running Windows.
- An account with Administrative privileges.
- PowerShell (or Windows PowerShell) installed on the system.
Step-by-Step
- Open PowerShell as Administrator: Right-click the Start button or search for "PowerShell" in the search bar. Right-click the result and select Run as administrator. If prompted by User Account Control (UAC), click Yes.
- View All Local Users: To see a list of all user accounts currently on the system, type the following command and press Enter:
net user - View Specific User Details: To see detailed information about a specific account (such as password expiration date or group memberships), type
net userfollowed by the username:net user username
(Replace "username" with the actual name of the account). - Create a New User Account: To add a new user to the system, use the following syntax:
net user username password /add
(Replace "username" with the desired name and "password" with a secure password). - Change or Reset a User Password: To change the password for an existing account, type:
net user username newpassword
(Replace "username" with the target account and "newpassword" with the new password). - Delete a User Account: To permanently remove a user account from the system, type:
net user username /delete
(Replace "username" with the account you wish to remove).
Common Mistakes
- Running without Admin rights: The most common error is attempting to run these commands in a standard PowerShell window. If you see "System error 5 has occurred. Access is denied," it means you are not running PowerShell as an Administrator.
- Forgetting Quotes for Names with Spaces: If a username contains a space (e.g., John Doe), the command will fail unless the name is enclosed in quotation marks.
Example:net user "John Doe" password /add - Typing Errors in Syntax: The
net usercommand is strict about its flags. Forgetting the forward slash beforeaddordeletewill result in an invalid command error.
Tips
- Hidden Password Entry: If you are working on a shared screen and do not want the password to be visible in the command history, use
net user username *. PowerShell will then prompt you to type and confirm the password without displaying the characters on the screen. - Account Management: Remember that
net usercreates a Standard User by default. If you need the new user to have administrative rights, you must add them to the administrators group using a separate command:net localgroup administrators username /add. - Case Sensitivity: While Windows usernames are generally not case-sensitive for login, it is best practice to type them exactly as they appear in the user list to avoid confusion.
Troubleshooting
If the commands do not go as planned, try these steps in order:
- Verify Admin Status: Check the top bar of your PowerShell window. It should say "Administrator: Windows PowerShell." If it only says "Windows PowerShell," close it and relaunch using the "Run as administrator" option.
- Check Username Spelling: Run the basic
net usercommand again to confirm the exact spelling of the account you are trying to modify. - Restart PowerShell: If the system seems to hang or fails to register a change, close the terminal and open a fresh session.
- Check for Group Policy Restrictions: In some corporate or school environments, Group Policy (GPO) may disable the ability to manage local users via the command line. If you are an admin but still receive "Access Denied," contact your network administrator.
Frequently Asked Questions
Can I use net user to unlock a locked account?
Yes. If an account is locked out due to too many failed password attempts, you can reset the password using net user username newpassword, which typically unlocks the account.
Does the net user command work on Mac or Linux?
No. The net user command is specific to the Windows operating system. macOS and Linux use different commands (such as useradd or dscl) for user management.
Will deleting a user with net user delete their files?
The net user username /delete command removes the user account from the system registry and login screen, but it does not automatically wipe the user's folder in C:\Users\. You must delete the user folder manually if you wish to reclaim disk space.
Is net user different from the New-LocalUser PowerShell cmdlet?
Yes. net user is a legacy Command Prompt tool that still works in PowerShell. New-LocalUser is a native PowerShell cmdlet. While they achieve the same result, net user is often preferred for its brevity and simplicity.
Can I change a user's group membership using net user?
No. The net user command is for account properties (passwords, creation, deletion). To change groups (like making a user an Administrator), you must use the net localgroup command.