AutomoxAutomox

Anyone make an Automox worklet to change the a local administrator user password?

cjohnson
December 10, 2024 at 6:29 pm UTC
#Worklets#powershell

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?

 

This discussion is archived and closed to replies. Continue it in the Automox Community Slack.

Discuss on Slack

Replies (3)

CallmePHDecember 17, 2024
#1

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!

cjohnsonDecember 17, 2024
#2

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

CallmePHDecember 18, 2024
#3

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!

powershell11 lines
# 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. $_"
}