Skip to content

Instantly share code, notes, and snippets.

@opragel
Last active March 31, 2017 18:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save opragel/8fa1015d9f4e2a3ea6ba30c087c2664f to your computer and use it in GitHub Desktop.
Save opragel/8fa1015d9f4e2a3ea6ba30c087c2664f to your computer and use it in GitHub Desktop.
sad_mdm.sh
#!/bin/bash
# dangerous, your funeral
# shoutout to rtrouton for jss comm checks
jamf_binary=$(/usr/bin/which jamf)
jss_comm_chk=$("$jamf_binary" checkJSSConnection > /dev/null; echo $?)
if [[ "$jss_comm_chk" -gt 0 ]]; then
/usr/bin/printf "Machine cannot connect to the JSS. Exiting."
elif [[ "$jss_comm_chk" -eq 0 ]]; then
/usr/bin/printf "Machine can connect to the JSS. Fixing MDM"
"$jamf_binary" removeMdmProfile -verbose
/usr/bin/profiles -D -f -v
# uncomment line 17 & 18 to
# nuke from orbit
# it's the only way to be sure
rm -rf "/Library/Keychains/apsd.keychain"
rm -rf /var/db/ConfigurationProfiles/*
"$jamf_binary" mdm -verbose
"$jamf_binary" mdm -userLevelMdm -verbose
"$jamf_binary" recon -verbose
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment