Windows server 2022 r2 change password command line

  • Home
  • Windows

Here's how to use the "net user" command line option to quickly change a password in Windows.

Command line interface with cartoon people sitting around it working on laptops

Need to change a user password in Windows 10 or 11? You can do this through the Settings app, but it's much faster and takes fewer clicks to change a password through the command line instead.

Even if you're new to text commands on Windows, changing the user password with the net user command is simple. We'll show you how to change a Windows password using the command line with this handy method.

Use the Net User Command to Change a Windows Password

To change another Windows user's password via the command line, you need administrator privileges. See how to get admin rights on Windows if you aren't using an admin account already.

Also, keep in mind that this method only works for local accounts in Windows 10 and 11. It won't work if you use a Microsoft account to sign in to Windows; you'll need to change the password using Microsoft's web account management page instead. See our guide to securing your Microsoft account for help with this and other security measures.

Now, here's how to change passwords via CMD using net user:

  1. Open an administrator Command Prompt window. To do this, type cmd into the Start menu, then right-click on the Command Prompt entry and choose Run as administrator.
    1. You can also use PowerShell or the Windows Terminal to perform this; you'll find a shortcut to those by right-clicking the Start button or hitting Win + X.
  2. Type the following net user command and press Enter to list all the users on your system. When they appear, take note of the account name you want to change the password for: net user
  3. To change a password, type the net user command shown below, replacing USERNAME and NEWPASS with the actual username and new password for the account. If the username is more than one word, you'll need to place it inside quotes, as shown: net user USERNAME NEWPASS net user "USER NAME" NEWPASS
  4. After you press Enter to run this command, you'll see a message that it completed successfully. Now you can use the new password to log into this account, just like if you had changed it via the graphical interface.

Windows 10 Change Password Net User

If you see an Access denied message when you try this, make sure that you started the Command Prompt (or other command line window) as an Administrator. Standard users can't change the password for other accounts. If you see an error that the username wasn't found, make sure you typed it correctly.

How to Privately Change a Password With Net User

You might want to prevent people around you from seeing the new password that you type when using net user. Thus, for more privacy, you can use a slightly different command to prevent the new password from appearing in plain text onscreen.

To do this, follow the above instructions, but type the following instead for step 3, replacing USERNAME with the actual username:

net user USERNAME *

Windows will then ask you to type a new password twice. However, the passwords don't appear as you type, making sure anybody nearby won't see them.

If you've lost your administrator password, follow our tips for resetting a lost Windows admin password.

Change Your Windows Password More Conveniently

Now you know how to use the net user command to change passwords in Windows. It's a quick way to change passwords without sorting through menus, plus you can change multiple passwords in quick succession without your hands leaving the keyboard.

Give it a try next time you need to change a user password. And when you set a new one, make sure to choose a strong password that's not easy to guess or crack.

When you connect to a Windows instance, you must specify a user account and password that has permission to access the instance. The first time that you connect to an instance, you are prompted to specify the Administrator account and the default password.

With AWS Windows AMIs for Windows Server 2012 R2 and earlier, the EC2Config service generates the default password. With AWS Windows AMIs for Windows Server 2016 and later, EC2Launch generates the default password.

With Windows Server 2016 and later, Password never expires is disabled for the local administrator. With Windows Server 2012 R2 and earlier, Password never expires is enabled for the local administrator.

Change the Administrator password after connecting

When you connect to an instance the first time, we recommend that you change the Administrator password from its default value. Use the following procedure to change the Administrator password for a Windows instance.

Store the new password in a safe place. You won't be able to retrieve the new password using the Amazon EC2 console. The console can only retrieve the default password. If you attempt to connect to the instance using the default password after changing it, you'll get a "Your credentials did not work" error.

To change the local Administrator password

  1. Connect to the instance and open a command prompt.

  2. Run the following command. If your new password includes special characters, enclose the password in double quotes.

    net user Administrator "new_password"
  3. Store the new password in a safe place.

Change a lost or expired password

If you lose your password or it expires, you can generate a new password. For password reset procedures, see Reset a lost or expired Windows administrator password.