How to change password using PowerShell on Windows 11

If you have a local account, you can use PowerShell to reset its password, and here's how on Windows 11.

Windows 11 PowerShell change password
Windows 11 PowerShell change password

On Windows 11, you can change the password of a local account using PowerShell commands in addition to using Command Prompt and Control Panel.

Usually, it’s no longer recommended to change the password if it hasn’t been compromised since it could lead to many other problems. However, if the password of your Windows 11 account has been compromised, or you realized it’s easy to guess, you can change it using PowerShell.

In this guide, you will learn the steps to use PowerShell to change the current password of a Windows 11 local account.

Change account password on Windows 11 with PowerShell

To change a local account password with PowerShell command on Windows 11, use these steps:

  1. Open Start.

  2. Search for PowerShell, right-click the top result, and select Run as administrator.

  3. Type the following command to list all the available accounts and press Enter:

    Get-LocalUser

    Get-LocalUser command

  4. Type the following command to create and store the new password in a variable and press Enter:

    $Password = Read-Host "Enter the new password" -AsSecureString
  5. Type the new password for the account and press Enter.

  6. Type the following command and press Enter on each line to apply the new password to the local account:

    $UserAccount = Get-LocalUser -Name "tempuser"
    $UserAccount | Set-LocalUser -Password $Password

    In the second command, make sure to replace “tempuser” with the name of the account to reset its password.

    Change password PowerShell command

Once you complete the steps, sign out and sign back into Windows 11 using the new password.

If you have to reset a password using Command Prompt, then use this other guide. Also, even though, this guide focuses on Windows 11, the above steps should also work on Windows 10, Windows 8.1, and Windows 7.

About the author

Mauro Huculak is a Windows How-To Expert who started Pureinfotech in 2010 as an independent online publication. He has also been a Windows Central contributor for nearly a decade. Mauro has over 14 years of experience writing comprehensive guides and creating professional videos about Windows and software, including Android and Linux. Before becoming a technology writer, he was an IT administrator for seven years. In total, Mauro has over 20 years of combined experience in technology. Throughout his career, he achieved different professional certifications from Microsoft (MSCA), Cisco (CCNP), VMware (VCP), and CompTIA (A+ and Network+), and he has been recognized as a Microsoft MVP for many years. You can follow him on X (Twitter), YouTube, LinkedIn and About.me. Email him at [email protected].