Created
December 22, 2015 00:25
-
-
Save rtrouton/fd965b16a9b4a7dc5d89 to your computer and use it in GitHub Desktop.
Script to fix Casper MDM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Identify location of jamf binary. | |
jamf_binary=`/usr/bin/which jamf` | |
if [[ "$jamf_binary" == "" ]] && [[ -e "/usr/sbin/jamf" ]] && [[ ! -e "/usr/local/bin/jamf" ]]; then | |
jamf_binary="/usr/sbin/jamf" | |
elif [[ "$jamf_binary" == "" ]] && [[ ! -e "/usr/sbin/jamf" ]] && [[ -e "/usr/local/bin/jamf" ]]; then | |
jamf_binary="/usr/local/bin/jamf" | |
elif [[ "$jamf_binary" == "" ]] && [[ -e "/usr/sbin/jamf" ]] && [[ -e "/usr/local/bin/jamf" ]]; then | |
jamf_binary="/usr/local/bin/jamf" | |
fi | |
# Verifies that the Mac can communicate with the Casper server. | |
# Once communication is verified, it takes the following actions: | |
# | |
# 1. Removes the existing MDM certificate if one exists | |
# 2. Runs jamf manage to fix the certificate | |
# 3. Runs a recon to send an updated inventory to the JSS to report | |
# that the MDM certificate is fixed. | |
# | |
jss_comm_chk=`"$jamf_binary" checkJSSConnection > /dev/null; echo $?` | |
if [[ "$jss_comm_chk" -gt 0 ]]; then | |
/usr/bin/logger "Machine cannot connect to the JSS. Exiting." | |
exit 0 | |
elif [[ "$jss_comm_chk" -eq 0 ]]; then | |
/usr/bin/logger "Machine can connect to the JSS. Fixing MDM" | |
"$jamf_binary" removeMdmProfile -verbose | |
"$jamf_binary" mdm -verbose | |
"$jamf_binary" recon | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment