--- title: "FileVault: Seamless Toggle On/Off and Key Rotation" slug: "filevault-seamless-toggle-onoff-and-key-rotation" updated: 2023-12-26T07:16:49Z published: 2023-12-26T07:16:49Z canonical: "help.scalefusion.com/filevault-seamless-toggle-onoff-and-key-rotation" --- > ## Documentation Index > Fetch the complete documentation index at: https://help.scalefusion.com/llms.txt > Use this file to discover all available pages before exploring further. # FileVault: Seamless Toggle On/Off and Key Rotation ## Toggle On/Off the FileVault The following Shell script helps IT Admins to toggle on/off the FileVault on the managed Mac devices. 1. Create a file on your desktop, for example, **ToggleFileVault.sh** and open it in a text editor like notepad++ 2. Copy the contents below to the file or click [here](https://cdn.document360.io/175c0eac-012f-4410-bdc5-ac60794f82d8/Images/Documentation/ToggleFileVault.sh) to download the file. ```bash #!/usr/bin/env bash # If should enable FileVault then set "yes" else "no" SHOULD_ENABLE="yes" # ====== DO NOT EDIT BELOW CODE ====== brandIcon="/Applications/Scalefusion-MDM Client.app/Contents/Resources/AppIcon.icns" title="Scalefusion: Disable FileVault" if [[ "$SHOULD_ENABLE" = "yes" ]]; then title="Scalefusion: Enable FileVault" fi ## Get the logged in user's name userName=$(/usr/bin/stat -f%Su /dev/console) ## Grab the UUID of the User userNameUUID=$(dscl . -read /Users/$userName/ GeneratedUID | awk '{print $2}') ## Get the OS build BUILD=`/usr/bin/sw_vers -buildVersion | awk {'print substr ($0,0,2)'}` ## This first user check sees if the logged in account is already authorized with FileVault 2 userCheck=`fdesetup list | awk -v usrN="$userNameUUID" -F, 'match($0, usrN) {print $1}'` if [ "${userCheck}" != "${userName}" ]; then echo "This user is not a FileVault 2 enabled user." exit 3 fi ## Check to see if the encryption process is complete encryptCheck=`fdesetup status` echo "${encryptCheck}" statusCheck=$(echo "${encryptCheck}" | grep "FileVault is On.") onStatus="FileVault is On." if [ "${statusCheck}" == "${onStatus}" ]; then    if [[ "$SHOULD_ENABLE" == "yes" ]]; then    echo "FileVault is already enabled"    exit 0    fi else    if [[ "$SHOULD_ENABLE" != "yes" ]]; then    echo "FileVault is already disabled"    exit 0    fi fi passwordPrompt () { ## Get the logged in user's password via a prompt echo "Prompting ${userName} for their login password." text="Admin has requested to disable FileVault" if [[ "$SHOULD_ENABLE" = "yes" ]]; then text="Admin has request to enable FileVault" fi userPass=$(/usr/bin/osascript <