Set Local Administrator Password With PowerShell

In this short and sweet blog post, I will show you how to set the local Administrator password on a Windows Server or client using PowerShell.

LocalUser

By default, Microsoft PowerShell comes with a built-in module to manage local users and groups.

Below, is the tow line code the will first ask you for a password and the second line will set the password to the local administrator account.

Note: You can change the account name to any account name that exists on the computer.

$pass = Read-Host -Prompt "Set Password" -AsSecureString
Set-LocalUser administrator -Password $pass
PS C: 
Set Password: 
PS C: \Users\vmadmin\Desktop> 
PS C: \Users\vmadmin\Desktop> 
*pass - 
Read - Host 
-Prompt "Set Password" -AsSecureString 
Set-Loca1User administrator -Password *pass

Posted

in

,

by