FileWave Alliance

The Official Community Forum
  • Page:
  • 1

TOPIC: Windows Script to Change Local Admin Password

Windows Script to Change Local Admin Password 24 Sep 2017 21:34 #2730

  • Morgan Gibbs
  • Morgan Gibbs's Avatar Topic Author
  • Offline
  • 1st level - White Belt
  • 1st level - White Belt
  • Posts: 3
  • Thank you received: 0
Greetings,

Our environment contains both macOS and Windows machines. On our macOS machines we push a simple activation script to change the local admin password a few times a year. We have just started working on similar filesets for our Windows machines and want to do the same thing.

I have tried creating an Activation Script to change the local admin password on all of our Windows machines, but it does not seem to work. I am using this DOS command, and ensuring that the Line Endings button is set to Windows on the script window:
net user admin Batman#1
(this would change the password of a local account named admin to Batman#1)

This command works fine in DOS, but I get an error message that says script execution failure (Time Out Exceeded) when I try to push this to my test machine. What is the trick to making scripts work in Windows? I can't find any documentation anywhere detailing this further.

Also, now that Windows 10 has a built-in bash shell, has anyone tried pushing bash commands to Windows via FileWave with any success?

Thank you.
Last Edit: by Morgan Gibbs.

Windows Script to Change Local Admin Password 25 Sep 2017 16:01 #2732

  • Bao Tran
  • Bao Tran's Avatar
  • Offline
  • FileWave Staff
  • FileWave Staff
  • Posts: 103
  • Karma: 4
  • Thank you received: 13
I tried this and it worked for me. Not sure why it's not working for you.

To troubleshoot I'd recommend appending the following to your commandline:

> %temp%\output.txt 2>&1

This redirects both stdout and stderr to %temp%\output.txt, which is normally c:\windows\temp\output.txt since the script is being run as the system account. Check this file or any error messages that may have come from your net user command execution.

Windows Script to Change Local Admin Password 25 Sep 2017 22:00 #2741

  • Morgan Gibbs
  • Morgan Gibbs's Avatar Topic Author
  • Offline
  • 1st level - White Belt
  • 1st level - White Belt
  • Posts: 3
  • Thank you received: 0
This is pretty odd. Real fast: I tried the .cmd, .bat, .com, .exeand .sh extensions. When I did this one more time the .cmd option took for some reason.

Thanks for your help! :)

Windows Script to Change Local Admin Password 08 Mar 2018 15:34 #2865

  • Jon Jones
  • Jon Jones's Avatar
  • Offline
  • 1st level - White Belt
  • 1st level - White Belt
  • Posts: 2
  • Thank you received: 0
Hi Morgan,

Sorry for digging up an old thread but I've got a question about your macOS password reset script.

Does your script also change password for Filevault and Keychain? I'm having some issues with this on our platform.

Cheers,
Jon

Windows Script to Change Local Admin Password 08 Mar 2018 15:55 #2866

  • Morgan Gibbs
  • Morgan Gibbs's Avatar Topic Author
  • Offline
  • 1st level - White Belt
  • 1st level - White Belt
  • Posts: 3
  • Thank you received: 0
Hey There,

I don't think it changes anything, but it might update in Keychain. It shouldn't change FileVault2, as that is not associated with a local account.

The script is very simple, and changes the password of a local account "admin" to "Batman#1":

#!/bin/bash

sudo dscl . -passwd /Users/admin "Batman#1"

exit 0

Windows Script to Change Local Admin Password 09 Mar 2018 10:21 #2868

  • Jon Jones
  • Jon Jones's Avatar
  • Offline
  • 1st level - White Belt
  • 1st level - White Belt
  • Posts: 2
  • Thank you received: 0
Thanks for this. It didn't update keychain but managed to find a way:

#!/bin/bash

sudo dscl . -passwd /Users/User "newpassword"; sudo security set-keychain-password -o oldpassword -p newpassword /Users/user/Library/Keychains/login.keychain-db

exit 0
  • Page:
  • 1