The below PowerShell script will Allow you to change the password of the local administrator account.
#!powershell
# Setup Key Values
###################################
$newpassword = “YourNewPassword”
$ErrorActionPreference = “Stop”
$hostname = “$env:computername”
# Create computer object
$computer = [ADSI](“WinNT://$hostname,computer”)
# Get local users list
$userList = $computer.psbase.Children | Where-Object { $_.psbase.schemaclassname -eq ‘user’ }
# Changing the Administrator Password Account
######################################################
foreach ($user in $userList)
{
# Create a user object in order to get its SID
$userObject = New-Object System.Security.Principal.NTAccount($user.Name)
$userSID = $userObject.Translate([System.Security.Principal.SecurityIdentifier])
# Look for local “administrator” SID
if(($userSID.Value.substring(0,6) -eq “S-1-5-“) -and ($userSID.Value.substring($userSID.Value.Length – 4, 4) -eq “-500″))
{
# Changing local administrator account password
$Error.Clear()
try
{
write-host ” ”
write-host “Changing local administrator password to $newpassword” -ForegroundColor Yellow
write-host ” ”
$localAdmin=[adsi]”WinNT://./$userObject,user”
$localAdmin.SetPassword($newpassword)
}
catch [System.UnauthorizedAccessException]
{
Write-Host “Could not change the password Access Denied” -ForegroundColor Red
}
}
}
###################### ANOTHER WAY ################################
If you would like something fast and dirty, this is a two line script
$Password = ConvertTo-SecureString “YourNewPasswordHere” -AsPlainText -Force
Set-LocalUser -Name “UserName” -Password $Password