Mac Script - How to update custom asset field with Bash script output

Mac Scripting Help - I created a quick script to see if FileVault is on (a one liner) but I’m trying to take that output and write it to the Syncro asset custom asset field.

sudo fdesetup status

It outputs something like “FileVault is On.” (or Off)"

Then use this:

# This can write to your Asset Custom Fields. Use it to store adhoc information that isn't currently surfaced.
syncro set-asset-field --name="Field Name" --value=$someVariable

To write it to the asset field.

I just need to know how to grab the “on” or “off” output and make it my $variable.

Anyone have a quick snippet or answer for this one? I checked the existing Mac scripts in the library (I’ll submit this one) and can’t find anyone else putting the variable to the asset field.

I have tried something someone put up on the FB group:

FDESETUP=$( sudo fdesetup status )

syncro set-asset-field --name="Field Name" --value=$FDESETUP

but that only put the work “FileVault” into the Syncro asset field. I’d like to get preferably ON or OFF or TRUE or FALSE into the field, but I’d even be ok with the whole string, “FileVault is ON” (or FileVault is OFF).


You can grep for On and store that, if it doesn’t exist, you can insert Off.

FDESETUP=$(fdesetup status | grep -o “On”)

So then basically do:

if [ “$FDESETUP” ]; then
syncro set-asset-field --name=“Field Name” --value=“$FDESETUP”
syncro set-asset-field --name=“Field Name” --value=“Off”

This should do the trick.