Password change script

Discussion in 'Mac Programming' started by spadz93, Apr 17, 2015.

  1. spadz93 macrumors member

    Joined:
    Nov 24, 2009
    #1
    I'm working in a school that's turning over their tech services to another company, so I need to change our admin accounts' passwords. I have the old password, and the account name is consistently admin. Is there a way I can incorporate the username, original password and new password in a single command, so that I can push out this command via ARD? I've tried using the methods outlined here but ARD's unix command window doesn't allow for additional input past the original command. Any help would be appreciated, would much rather push this out than have to do this individually.
     
  2. superscape macrumors 6502a

    superscape

    Joined:
    Feb 12, 2008
    Location:
    East Riding of Yorkshire, UK
    #2
    Hi,

    Does this do it?

    I think you'll need to do it from an account with admin privs, or sudo it.

    Hope that helps

    Rob
     
  3. spadz93 thread starter macrumors member

    Joined:
    Nov 24, 2009
    #3
    this gets my foot in the door. i still need the keychain to be unlocked via the old password, but it changed the password for the account
     
  4. superscape macrumors 6502a

    superscape

    Joined:
    Feb 12, 2008
    Location:
    East Riding of Yorkshire, UK
  5. spadz93 thread starter macrumors member

    Joined:
    Nov 24, 2009
    #5
    how would i implement that, just by doing this?...

    Code:
    sudo dscl . -passwd /Users/USERNAME NEWPASS
    i used an osascript sequence to automate it, and it's been working pretty well. entire command process below

    Code:
    dscl . -passwd /Users/USERNAME NEWPASS
    
    osascript <<EOF
    tell application "System Events"
    keystroke "USERNAME"
    keystroke tab
    delay 0.5
    keystroke "NEWPASS"
    delay 0.5
    keystroke return
    delay 3.0
    keystroke return
    delay 0.5
    keystroke "OLDPASS"
    delay 0.5
    keystroke return
    end tell
    EOF
    basically this just walks it through the on-screen prompts to authenticate the keychain update
     

Share This Page