Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

How to Set a Windows 10 Local Account Password With PowerShell

Use Set-LocalUser to set a new password for a local Windows account without exposing it in the command, and verify the change safely.

Table of Contents

On a Windows 10 PC you administer, use Set-LocalUser to set a new password for a local account. For a routine change to your own account when you know the old password, Settings > Accounts > Sign-in options is usually easier. A Microsoft account, work account, and Windows Hello PIN have separate procedures.

Confirm you are changing the right account

Open Windows PowerShell as administrator. On 64-bit Windows, use the 64-bit app. The LocalAccounts module is unavailable in the 32-bit PowerShell process on a 64-bit system. Run this to list accounts and their status:

Get-LocalUser | Select-Object Name, Enabled

Check the exact local account name. On a shared or managed PC, change another user’s password only when you have authority and have followed the applicable recovery procedure. An administrative reset can affect access to credentials and files encrypted by that user.

Instructions to change Windows 10 password using PowerShell Picture 1

Instructions to change Windows 10 password using PowerShell Picture 2

Instructions to change Windows 10 password using PowerShell Picture 3

Enter the new password at a secure prompt

$account = Get-LocalUser -Name 'AccountName' -ErrorAction Stop
$password = Read-Host 'Enter the new password' -AsSecureString
Set-LocalUser -InputObject $account -Password $password -ErrorAction Stop
Remove-Variable password

Replace AccountName before running the commands. At the prompt, type the new password and press Enter. Enter it at the prompt instead of writing it directly into the command or saving it in a script. If PowerShell reports a password policy error, choose a password that meets the displayed requirements. See Microsoft’s Set-LocalUser reference.

Instructions to change Windows 10 password using PowerShell Picture 4

Instructions to change Windows 10 password using PowerShell Picture 5

Instructions to change Windows 10 password using PowerShell Picture 6

Instructions to change Windows 10 password using PowerShell Picture 7

Verify the new password

Save open work and use Switch user to test the affected account, or sign out when you have confirmed another recovery path. Select the password sign-in option if Windows shows a PIN field first. A restart is generally unnecessary. See the Windows sign-in settings guide or what to do if the password expired.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.