Skip to main content

I’m trying to use automox to reset a local user on a bunch of windows 10 machines. But I keep getting an error.

# Define the username and new password
$scriptBlock = {
$adminUsername = "Local User"
$newPassword = "Password"
$securePassword = ConvertTo-SecureString -String $newPassword -AsPlainText -Force
Set-LocalUser -Name $adminUsername -Password $securePassword -ErrorAction SilentlyContinue
}
$exitCode = & "$env:SystemRoot\sysnative\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -WindowStyle Hidden -NoProfile -NonInteractive -Command $scriptBlock

 

Anyone been able to make this work?

 

So I have not been able to get the secure string part to work. I have one that does change a local user/admin(as long as you have renamed the default admin) account, and I then clear the passed PW. It isnt elegant or 100% secure for sure, but it does work!


@CallmePH Any chance you could share the script/worklet?


Sure! it is super simple and does work if you have renamed the Administrator default to something else!

Has bailed me out a few times on some laptops!

# Define the username and new password
$Username = "local user"
$NewPassword = "local user password"

# Attempt to set the new password for the user
try {
net user $Username $NewPassword
Write-Output "Password for user $Username successfully changed."
} catch {
Write-Output "Error: Failed to change password for user $Username. $_"
}

 


Reply