PowerShell script to Remotely Enable a Local administrator Account and set a password.

PowerShell script to Remotely Enable a Local administrator Account and set a password.

After completing the Windows 10 installation, the original built-in administrator’s account is disabled by default.

There may be situations where one would like to use the built-in administrator account instead of the new user.

Using the below script we can enable a local or remote computer local administrator password.

The script contains some variables need to be a change.Add Remote computer IP/Hostname and enter a password for the user

 #variables .Change as per your needs
 $username = "administrator"; 
$computer="192.168.8.8"    #Change this
$password ="Secret$password"    #Change this
 #No need to Change the below lines
$EnableUser = 512
try {
$user = [ADSI]"WinNT://$computer/$username";
$user.SetPassword($password);
$user.UserFlags =$EnableUser     
 $user.setinfo()
Write-Host "Success" -ForegroundColor green
 }
 catch
 {
 write-host "an error occured $_" -ForegroundColor Red
 }

Comments