Skip to main content
Solved

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

  • December 10, 2024
  • 3 replies
  • 142 views

Forum|alt.badge.img

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?

 

Best answer by CallmePH

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

 

View original
How helpful was this post to you?

3 replies

CallmePH
Forum|alt.badge.img
  • Pro
  • 51 replies
  • December 17, 2024

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!


Forum|alt.badge.img
  • Author
  • Rookie
  • 1 reply
  • December 17, 2024

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


CallmePH
Forum|alt.badge.img
  • Pro
  • 51 replies
  • Answer
  • December 18, 2024

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings