Create script in automator to change recovery key

New Contributor

Hey ,

I've been using JAMF NOW for a several months now at my company for Macbooks. I'm trying to write a script to change the recovery and get the recovery key in Jamf. I'm trying to write the script like a way that the user only has to login in with their administrator account account and that the script will run in terminal. These are the possibilities I've tried in "Automator"

osascript -e "do shell script "mkdir -p /var/db/sudo/$USER; touch /var/db/sudo/$USER" with administrator privileges" &&
sudo -S fdesetup changerecovery -personal

osascript -e 'tell app "Terminal" do script "sudo fdesetup changerecovery -personal"
end tell'

pw="$(osascript -e 'Tell application "System Events" to display dialog "Password:" default answer "" with hidden answer' -e 'text returned of result' 2>/dev/null)" && / echo "$pw" | sudo -S fdesetup changerecovery -personal

I've tried several scripts but they aren't working they send me to the terminal but they don't run the script or I get an error message that the login is not correct