Enabling FileVault is a critical step in securing macOS devices, particularly in managed environments like schools, enterprises, and remote teams. For administrators using Jamf Pro, automating this process can simplify device onboarding and ensure compliance with disk encryption policies.
One such script, Add_FV_Prompt.sh, helps automate the addition of users to FileVault by prompting for credentials via osascript and passing them to fdesetup. While it’s functional and useful in certain edge cases, there are security caveats to be aware of.
⚙️ What the Script Does
The Add_FV_Prompt.sh script enables FileVault for a target user by automating the following steps:
- Prompts the user for their username and password using
osascriptdialogs. - Prompts for the admin account’s username and password.
- Uses
expectto automate the interaction with thefdesetup addcommand, feeding in the required credentials.
🔐 osascript Prompts
The script uses two forms of AppleScript via osascript to request input:
adminName=`osascript -e 'Tell application "System Events" to display dialog "Enter your username: Your username is the first initial and last name all lowercase no spaces" default answer ""' -e 'text returned of result'`
adminPass=`osascript -e 'Tell application "System Events" to display dialog "Enter your password:" with hidden answer default answer ""' -e 'text returned of result'`
The first line prompts for the username — this is visible plaintext input, which presents less risk.
The second line prompts for the password using the with hidden answer clause — this masks input from view but does not securely handle the password:
- The value is still stored in a shell variable (
$adminPass). - It can be read from memory during execution.
- It may still show in logs or crash dumps under certain conditions.
⚠️ Hidden input in AppleScript does not equate to encryption. It is merely UI-level obfuscation.
💡 What Happens Next
After collecting the credentials, the script pipes them into fdesetup using expect automation:
expect -c "
spawn sudo fdesetup add -usertoadd $userName
expect "Enter the user name:"
send ${adminName}
expect "Enter the password for user '$adminName':"
send ${adminPass}
expect "Enter the password for the added user '$userName':"
send ${userPass}
expect eof
"
This allows non-interactive FileVault user addition, which is helpful in environments where user interaction is not ideal or available — such as lab setups or remote support sessions.
⚠️ Security Warning
While the automation is convenient, passing passwords in plain-text variables is a security risk:
- Even though the password dialog masks input, the resulting shell variable (
$adminPass,$userPass) is in memory. - On some MDM platforms like Jamf, script parameters — even hidden — can be written to log output, making them visible to admins or attackers with access.
- The
expectprocess can also expose these values in real-time if not sandboxed or locked down.
Recommendation: Only use this script in low-risk or one-off situations, such as lab environments, loaner devices, or when users are being onboarded under direct supervision.
For more secure environments, consider using Jamf’s native FileVault configuration profiles, secure tokens escrowed during DEP enrollment, or triggering fdesetup manually via Self Service with user input.
🧪 When to Use This Script
- 🔧 You need to re-enable FileVault for a user without triggering full disk decryption.
- 🧑💻 You’re working in a lab or low-security environment where credentials are temporary or non-sensitive.
- ⚠️ You understand and accept the logging risks associated with passing credentials in scripts.
📝 Final Thoughts
Scripts like Add_FV_Prompt.sh can be powerful tools in the right context — but with great power comes great responsibility. Security professionals and MacAdmins should always weigh convenience against risk.
If you choose to use this script:
- Restrict who can deploy or trigger it.
- Avoid reusing admin credentials.
- Rotate passwords after use if possible.
For a look at the script, visit the repo:
👉 Add_FV_Prompt.sh
Stay secure and script smart. 💻🔒
Ready to take your Apple IT skills and consulting career to the next level?
I’m opening up free mentorship slots to help you navigate certifications, real-world challenges, and starting your own independent consulting business.
Let’s connect and grow together — Sign up here
AI Usage Transparency Report
AI Era · Written during widespread use of AI tools
AI Signal Composition
Score: 0.35 · Moderate AI Influence
Summary
A script to automate FileVault user addition, but with security caveats and recommendations for secure use.
Related Posts
Understanding GitHub Actions Before You Let Them Run
New to GitHub Actions? Learn what they are, where they come from, how AI uses them, and the review process I follow before trusting third-party Actions in production.
Audit Jamf API Roles Before They Become Forgotten Access
A read-only Jamf Pro API role audit script that reports role privilege reach, write-capable access, review priority, and API client inventory without changing Jamf.
Opening the Ollama Black Box: Understanding the Trust Boundary Behind Local AI
Installing Ollama is easy. Understanding the trust boundary behind a local AI service is what determines whether it belongs in an automation workflow.
Your Vibe-Coded App Still Needs a Trustworthy Release Path
Why vibe-coded apps still need release discipline: code signing, notarization, checksums, and GitHub artifact attestations all support integrity and user trust.
Secure Storage Isn't Enough: Using Secrets Safely in Admin Automation
Secret managers protect stored credentials. They don't automatically protect how your automation uses them. Here's the review process I use before workflows reach production.
What I Check Before I Trust a Homebrew Formula or Cask
Homebrew gives Mac admins a useful first-pass inspection workflow before trusting a formula or cask: check the source, checksum, version, tap state, availability, and upstream maintenance story.
Adobe in Jamf: To Package or Not to Package
A Jamf Pro workflow for deciding when Adobe software should be deployed as a manual Adobe package and when the Jamf App Catalog path is the better fit.
When a Local AI Tool Belongs in My Workflow and When It Stays in the Lab
Running AI locally on a Mac has become a real part of my workflow, but only once I stopped treating local models like general-purpose answers and started treating them like constrained components inside a system I can still inspect.
Discovering Mole: A Command Line Utility for Mac Cleaning
Caches pile up, apps leave behind junk, and disk space slowly disappears. While there are plenty of GUI tools out there, most of them either lack transparency or feel overly bloated.
Scoring AI Influence in Jekyll Posts with Local LLMs
There’s a moment that kind of sneaks up on you when you’ve been writing for a while, especially if you’ve started using AI tools regularly. You stop asking whether AI was used at all, and instead start wondering how much it actually shaped what you’re reading. That shift is subtle, but once you notice it, you can’t really unsee it.