Category filter
Script to check if Find My Mac is enabled on Mac
Find My Mac is an Apple service that helps users track or locate their macOS devices. It’s essential to have this security feature enabled to safeguard any critical corporate/personal data in case the device is lost or stolen. Admins can check whether ‘Find My Mac’ is enabled or disabled by executing this script with Hexnode’s Execute Custom Script action.
Scripting language – Shell
File extension – .sh
Check if Find My Mac is set up
1 2 3 4 5 6 7 8 9 10 |
#!/bin/sh fmmToken=$(/usr/sbin/nvram -x -p | /usr/bin/grep fmm-mobileme-token-FMM) if [ -z "$fmmToken" ]; then echo "<result>Find My Mac is disabled</result>" else echo "<result>Find My Mac is enabled</result>" fi |
/usr/sbin/nvram -x –p: The
/usr/bin/grep fmm-mobileme-token-FMM: The extracted data which is in XML format is filtered using ‘grep’ to find the ‘fmm-mobileme-token-FMM’ string, which corresponds to the ‘Find My Mac’ token.
The ‘if’ condition checks whether the ‘fmmToken’ variable is empty or not. If the token is empty, it means ‘Find My Mac’ is not enabled on the device.
The above script will return the output “Find My Mac is enabled” if ‘Find My Mac’ option is enabled in the device. The output of the script execution can be verified from the Action History page of the device.
If ‘Find My Mac’ option is disabled, the script returns the output as “Find My Mac is disabled”.
The ‘Find My Mac is disabled’ output may also indicate the absence of an associated Apple ID account. Admins can check if an Apple ID account is associated with device or not by using the Script to fetch the Apple IDs of users on Mac.