Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
"Type" old and new passwords into Windows Server 2016 change password screen went WorkSpaces doesn't allow pasting from your Mac.
#!/usr/bin/osascript
# Usage:
# export OLDPASS="oldpasswordhere!"
# export NEWPASS="newpasswordgoeshere."
# get to change password screen in WorkSpace prior to running this script and make sure you're on the "old password" field.
# run script without args
on sysKeyCode(kc)
tell application "System Events" to key code {kc} using {command down}
end sysKeyCode
on sysKeyStroke(ks)
tell application "System Events" to keystroke ks
end
on sendString(thePass)
set AppleScript's text item delimiters to ""
repeat with letter in thePass
if (letter = "0") then
sysKeyCode(29)
else if (letter = "1") then
sysKeyCode(18)
else if (letter = "2") then
sysKeyCode(19)
else if (letter = "3") then
sysKeyCode(20)
else if (letter = "4") then
sysKeyCode(21)
else if (letter = "5") then
sysKeyCode(23)
else if (letter = "6") then
sysKeyCode(24)
else if (letter = "7") then
sysKeyCode(26)
else if (letter = "8") then
sysKeyCode(28)
else if (letter = "9") then
sysKeyCode(25)
else if (letter = ".") then
sysKeycode(47)
else
sysKeyStroke(letter)
end if
delay 0.1
end repeat
end sendString
set oldPassword to system attribute "OLDPASS"
set newPassword to system attribute "NEWPASS"
activate application "WorkSpaces"
sendString(oldPassword)
sysKeyStroke (ASCII character 9)
sendString(newPassword)
sysKeyStroke(ASCII character 9)
sendString(newPassWord)
end activate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment