Home > Jamf Pro, Jamf Pro API, Jamf Pro Classic API > Clearing failed MDM commands from members of Jamf Pro smart or static groups
A while back, I had posted about a solution for clearing failed MDM commands on a per-computer basis. I recently learned it’s also possible to clear them by using an API command which clears failed MDM commands from all members of a specified Jamf Pro smart or static group. This approach works for both computer groups and mobile device groups. For example, if you wanted to clear all failed MDM commands for members of a mobile device group, you could use a command like the one shown below:
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
If you wanted to clear all failed MDM commands for members of a computer group, you could use a command like the one shown below:
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
In both cases, the following API permission would be required:
Flush MDM Commands
If using a user account to authenticate to the API, this permission would be set in Jamf Pro Server Actions:
If using an API client to authenticate to the API, this permission would be set in an API role:
For folks who want to use this method to clear failed API commands, I’ve written a couple of scripts to assist with this. For more details, please see below the jump.
I’ve posted both scripts to the following location:
Both scripts are designed to use API client authentication, with the following permissions assigned:
clear_failed_Jamf_Pro_mdm_commands_from_computer_group.sh
clear_failed_Jamf_Pro_mdm_commands_from_mobile_device_group.sh
Both scripts are designed to use the Jamf Pro ID number for a specified Jamf Pro smart or static group to do the following:
The scripts will produce errors in the following cases:
Successful output should look like this for the following scripts:
clear_failed_Jamf_Pro_mdm_commands_from_computer_group.sh
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
username@computername ~ % /path/to/clear_failed_Jamf_Pro_mdm_commands_from_computer_group.sh | |
Please enter your Jamf Pro server URL : https://jamf.pro.server.goes.here | |
Please enter your Jamf Pro API client ID : 7eda98e3-12ea-469c-8c45-4e070b5003cb | |
Please enter the API client secret for the 7eda98e3-12ea-469c-8c45-4e070b5003cb API ID client: | |
The smart or static computer group you want to clear failed MDM commands from has not been specified. | |
Please enter the Jamf Pro ID of the smart or static computer group : 1 | |
Clearing failed MDM commmands from members of the following group: All Managed Clients | |
<?xml version="1.0" encoding="UTF-8"?><commandflush><status>+failed</status><computer_groups>[1]</computer_groups></commandflush> | |
Failed MDM commands successfully cleared from members of the following group: All Managed Clients | |
username@computername ~ % |
clear_failed_Jamf_Pro_mdm_commands_from_mobile_device_group.sh
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
username@computername ~ % /path/to/clear_failed_Jamf_Pro_mdm_commands_from_mobile_device_group.sh | |
Please enter your Jamf Pro server URL : https://jamf.pro.server.goes.here | |
Please enter your Jamf Pro API client ID : 7eda98e3-12ea-469c-8c45-4e070b5003cb | |
Please enter the API client secret for the 7eda98e3-12ea-469c-8c45-4e070b5003cb API ID client: | |
The smart or static mobile device group you want to clear failed MDM commands from has not been specified. | |
Please enter the Jamf Pro ID of the smart or static mobile device group : 1 | |
Clearing failed MDM commmands from members of the following group: All Managed Apple TVs | |
<?xml version="1.0" encoding="UTF-8"?><commandflush><status>+failed</status><mobile_device_groups>[1]</mobile_device_groups></commandflush> | |
Failed MDM commands successfully cleared from members of the following group: All Managed Apple TVs | |
username@computername ~ % |