Just wanted to share this. I've had some specific use case scenarios where people have enabled FileVault outside of Jamf, and it's necessary to decrypt the machine and then perform encryption over again to get the recovery key escrowed in Jamf properly. It's not perfect, but I wrote this script to be used in Self Service by the user. Since the fdesetup disable command requires the user's password, you can't remotely disable FileVault (unless you know a FV enabled user's password or recovery key on the machine, which chances are you won't know if FV was enabled improperly). This seemed to be the next best option in my case so I didn't have to go around to every machine and run it. Tested on 10.13 and 10.14 machines. Cheers.
#!/bin/sh
# Get logged in user
USER=$( ls -l /dev/console | awk '{print $3}' )
# Check if FileVault is already off - no need to run script if so
if fdesetup status | grep -q Off; then
/usr/bin/osascript <<EOT
tell application "System Events"
activate
display dialog "FileVault is already Off. Exiting" buttons {"OK"} default button 1
if button returned of result is "OK" then
end if
end tell
EOT
exit 0
fi
# Prompt user for credentials
PASS=$(/usr/bin/osascript <<EOT
tell application "System Events"
activate
display dialog "Please enter your password to disable FileVault:" default answer "" with hidden answer
if button returned of result is "OK" then
set pw to text returned of result
return pw
end if
if button returned of result is "Cancel" then
error number -128
end if
end tell
EOT)
# end script if no password is entered or cancel is pressed
if [ -z "$PASS" ]
then
exit 0
fi
# Disable FileVault
/usr/bin/expect <<EOT
spawn fdesetup disable
expect ":"
sleep 1
send -- "$USER
"
expect ":"
sleep 1
send -- "$PASS
"
expect ":"
sleep 1
send -- "
"
EOT
# Sleep for 2 seconds to allow time for command to complete
sleep 2
# Check if computer is decrypting, display results to user
if fdesetup status | grep -q Decryption; then
/usr/bin/osascript <<EOT
tell application "System Events"
activate
display dialog "Your computer is currently decrypting. You can check the status in System Preferences > Security & Privacy > FileVault." buttons {"OK"} default button 1
if button returned of result is "OK" then
end if
end tell
EOT
else
/usr/bin/osascript <<EOT
tell application "System Events"
activate
display dialog "There was a problem disabling FileVault. Please try again or contact your System Administrator." buttons {"OK"} default button 1
if button returned of result is "OK" then
end if
end tell
EOT
fi
exit 0