- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to change the local user account password using PowerShell?
To change the local user account password using PowerShell, we can use the Set-LocalUser command with the Password parameter. This password parameter should be in the secure string. So we need to ask the user to input the password as a secure string or need to explicitly convert the plain text password to the secure string. For example,
$localuser = Read-Host "Enter Local UserName" $password = Read-Host "Enter local user account password " -AsSecureString Set-LocalUser -Name $localuser -Password $password -Verbose
If you need to set the password without asking the user prompt then you need to convert the plain text password to the secure string forcefully as shown below.
$password = "Admin123" | ConvertTo-SecureString -AsPlainText -Force Set-LocalUser -Name TestUser -Password $password -Verbose
To set the local user password on the remote computer, use Invoke-Command.
Invoke-Command -ComputerName Computer1, Computer2 -ScriptBlock{ $password = "Admin123" | ConvertTo-SecureString -AsPlainText -Force Set-LocalUser -Name 'TestUser' -Password $password -Verbose }
The above command will set the local user account password on the remote servers computer1 and Computer2.
- Related Articles
- How to set the local user account settings using PowerShell?
- How to find the locked local user accounts using PowerShell?
- How to get the disabled local user accounts using PowerShell?
- How to change the local disk name using PowerShell?
- How to add the user to the local Administrators group using PowerShell?
- How can we change MySQL user password by using the SET PASSWORD statement?
- How to create a new local user in windows using PowerShell?
- How can we change MySQL user password by using the ALTER USER statement?
- How to enable or disable local user on Windows OS using PowerShell?
- How to change the password in MongoDB for existing user?
- How can we change MySQL user password by using UPDATE statement?
- How to connect Azure Account using PowerShell?
- How to get the currently logged-in user account with Azure CLI in PowerShell?
- How to generate a strong password using PowerShell?
- How to Force User to Change Password at Next Login in Linux?

Advertisements