Net User: CMD Command to Create Users and Change Passwords

In this tutorial, you will learn how to use the net user command to create, delete and change user accounts in the Windows command prompt (CDM).

We can perform the following tasks using the net user command:

  • View user accounts.
  • Add and Remove user accounts.
  • Activate and Deactivate user accounts.
  • Change the user password.

If you are operating in an Active Directory domain environment, always use the /domain command switch to execute the net user command on the domain controller rather than on the local computer.

Examples

List users on the local computer:

net user

List users on the domain controller:

net user /domain

This command displays detailed information about the Administrator account:

net user Administrator

Create a user named user1 with a password of strongPassword:

net user /add user1 "strongPassword"

Delete the user user1 from the computer:

net user /delete user2

This command enables the built-in Administrator account on Windows 10/11:

net user Administrator /active:yes

This command sets (changes) the Administrator account password:

net user Administrator "adminPassWord"

Execute the following command to disable the Administrator account on Windows 10/11:

net user Administrator /active:no

This command forces the user user1 to change the password at the next logon:

net user user1 /logonpasswordchg:yes

Create a user; the user must change the password at the next logon:

net user /add user1 "strongPassword" /logonpasswordchg:yes

Create a new user; the account expires on January 31st:

net user /add user1 "strongPassword" /expires:01/31/2023

Command Options

usernameThe name of the user to create, delete, view, or modify.
passwordPassword for the user.
*Use this option to produce a prompt for the password.
/addUse this option when you want to create a new user.
/deleteUse this option to remove a user from the Windows system.
/active:{yes | no}Activates or Deactivates a user. The default is yes when creating a new user.
/expires:{date | never}Use this option to set the expiration date (mm/dd/yy) for an account. The default is never.
/fullname:"name"Full name of the user.
/passwordchg:{yes | no}Specifies whether users can change their own password. The default is yes.
/passwordreq:{yes | no}No means the user can log in without a password. The default is YES.
/logonpasswordchg:{yes|no}Specifies whether the user should change the password at the next logon. The default is NO.
/homedir:pathThe home directory location.
/comment:"text"Use this option to add a description to the user's account.

You can view the manual page by typing net help user at the command prompt.

View a User

When you execute the net user command without any options, it displays a list of user accounts on the computer.

net user

You will see an output similar to the following:

the net user command

Add the /domain command switch if you want to list users on the Active Directory Domain controller.

net user /domain

To see detailed information about a particular user, execute the command net user Username, where the Username is the name of the user you want to view. For example, you can view the Administrator account by running the following command:

net user Administrator

Create and Delete User Accounts

To create a user account, use the following syntax:

net user /add UserName Password

For example, the following command creates a user named user1 with a password of strongPassword:

net user /add user1 "strongPassword"

Use an asterisk (*) in place of the password to produce a prompt, as shown in the following example:

net user /add user1 *
net user change password
Change Password

Alternatively, you can also use the /random option to generate a strong random password, as shown in the following example:

net user /add user1 /random

The randomly generated password will be displayed on the command prompt after you execute the command.

Using Net User command to generate a strong random password
Using Net User command to generate a strong random password

To delete a user, use the following syntax:

net user /delete UserName

The following command deletes the user user1 from the computer:

net user /delete user2

Change Passwords

To change passwords, use the following syntax:

net user UserName New-Password

Use an asterisk (*) or /random in place of the password to produce a prompt or generate a random password:

net user UserName *
net user user1 /random

Notes

The net user command is most of the time used in Windows Server to manage Active Directory users.

Windows 10/11 uses a new Settings pane to manage users, but the net user command is still useful for some tasks. For example, if you want to activate the built-in Administrator account, it is easy to do that using this command.

While working at the command prompt, run the net help user command to see all available command options.

In the next tutorial, we are going to learn how to manage Windows groups using the net localgroup CMD command.