Quantcast
Channel: rtrouton – Der Flounder
Viewing all articles
Browse latest Browse all 764

Updating management status in Jamf Pro computer inventory records on Jamf Pro 10.49.0 and later

$
0
0

As of Jamf Pro 10.49.0, the following mass action has been removed:

  •  Edit the Management Account Information

Screen Shot 2021 09 28 at 10 39 53 AM

I had been using this to update the status of unmanaged Macs to now be managed Macs, by editing the username and password assigned to the computer inventory record. As part of this, the remote management status of the computer inventory record would change from Unmanaged to Managed.

As of Jamf Pro 10.49.0, the management account information has been removed from the computer inventory record, with the resulting removal of the mass-action to edit the management account information. However, this has left me without a mass-action to change unmanaged Macs to managed Macs.

Fortunately, there’s a way to change this via the Jamf Pro Classic API. The relevant API command to change the management status in a Jamf Pro computer inventory record should look like this:



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


/usr/bin/curl -H "content-type: text/xml" "https://jamf.pro.server.here/JSSResource/computers/id/jamf_pro_computer_ID_goes_here&quot; –header "Authorization: Bearer api_token_goes_here" -X PUT -d "<computer><general><remote_management><managed>true</managed></remote_management></general></computer>"
view raw

gistfile1.txt

hosted with ❤ by GitHub

It’s sending the following XML block to update the relevant computer inventory record and make the management change:



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


<computer>
<general>
<remote_management>
<managed>true</managed>
</remote_management>
</general>
</computer>
view raw

gistfile1.txt

hosted with ❤ by GitHub

Previously, you also needed to send along the management username and management password, but since those have been removed as of Jamf Pro 10.49.0, those are no longer needed.

I have filed a feature request with Jamf to get back an equivalent mass-action to update the management status. For those interested, it is the following:

JN-I-27551: https://ideas.jamf.com/ideas/JN-I-27551

While I wait to see what Jamf does with the feature request, I was able to use the API information discussed above to create a script which a) updates the management status in specified computer inventory records and b) generates a report of the Macs whose computer inventory records were updated. For more details, please see below the jump.

The script is named Set_Jamf_Pro_Computers_To_Managed_Status.sh and is available via the link below:

https://github.com/rtrouton/rtrouton_scripts/tree/main/rtrouton_scripts/Casper_Scripts/Set_Jamf_Pro_Computers_To_Managed

The script is designed to take in a set of Jamf Pro ID numbers in a plaintext file, where the Jamf Pro ID numbers correspond the Macs where you want to change the management status in their Jamf Pro computer inventory records. The plaintext file should look similar to this:



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


416462
842736
434703
338517
481915
596669
view raw

gistfile1.txt

hosted with ❤ by GitHub

Five items are required to use this script:

  • Jamf Pro 10.49.0 or later
  • A text file containing the Jamf Pro IDs of the computer(s) you wish to delete.
  • The URL of the appropriate Jamf Pro server.
  • The username of an account on the Jamf Pro server with sufficient privileges to delete computers from the Jamf Pro server.
  • The password for the relevant account on the Jamf Pro server.

Jamf Pro account privileges required by the Jamf Pro server account referenced above:

Jamf Pro Server Objects:

Computers: Read, Update

Users: Update

Once the five specified items are available, the script can be run using the following command:



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


/path/to/Set_Jamf_Pro_Computers_To_Managed_Status.sh /path/to/plaintext_filename_here.txt
view raw

gistfile1.txt

hosted with ❤ by GitHub

You should see output like this:



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 ~ % /Users/Shared/Set_Jamf_Pro_Computers_To_Managed/Set_Jamf_Pro_Computers_To_Managed_Status.sh /Users/Shared/jamfpro_computer_ids.txt
Please enter your Jamf Pro server URL : https://jamf.pro.server.here
Please enter your Jamf Pro user account : username_goes_here
Please enter the password for the username_goes_here account:
Report being generated. File location will appear below once ready.
<?xml version="1.0" encoding="UTF-8"?><computer><id>416462</id></computer>
Updated management status in the computer inventory record for https://jamf.pro.server.here/computers.html?id=416462 from unmanaged to managed.
<?xml version="1.0" encoding="UTF-8"?><computer><id>842736</id></computer>
Updated management status in the computer inventory record for https://jamf.pro.server.here/computers.html?id=842736 from unmanaged to managed.
<?xml version="1.0" encoding="UTF-8"?><computer><id>434703</id></computer>
Updated management status in the computer inventory record for https://jamf.pro.server.here/computers.html?id=434703 from unmanaged to managed.
<?xml version="1.0" encoding="UTF-8"?><computer><id>338517</id></computer>
Updated management status in the computer inventory record for https://jamf.pro.server.here/computers.html?id=338517 from unmanaged to managed.
<?xml version="1.0" encoding="UTF-8"?><computer><id>481915</id></computer>
Updated management status in the computer inventory record for https://jamf.pro.server.here/computers.html?id=481915 from unmanaged to managed.
<?xml version="1.0" encoding="UTF-8"?><computer><id>596669</id></computer>
Updated management status in the computer inventory record for https://jamf.pro.server.here/computers.html?id=596669 from unmanaged to managed.
Report on Macs available here: /var/folders/vd/c27hl4p53j1_5cnv9ynpxp6m0000gn/T/tmp.iJDgJwhq.tsv
username@computername ~ %
view raw

gistfile1.txt

hosted with ❤ by GitHub

As part of the script’s run, a report will be generated and you’ll be notified of where it is stored. The report will be in TSV format and appear similar to what’s shown below:



Jamf Pro ID Number Make Model Serial Number UDID Computer Management Status Jamf Pro URL
416462 Apple MacBook Pro (16-inch, 2019) WD8JB8F49YS4 4D8CD419-1892-4CFE-8D18-D1DD53CC7970 Managed https://jamf.pro.server.here/computers.html?id=416462
842736 Apple MacBook Pro (16-inch, 2019) R6JG7GYVNORW 904418F7-3695-44BF-9A00-74F5CF617377 Managed https://jamf.pro.server.here/computers.html?id=842736
434703 Apple MacBook Pro (16-inch, 2019) FWPATJHWC92O 5CF418CE-3E46-481C-A171-7ACC9E1E2E7A Managed https://jamf.pro.server.here/computers.html?id=434703
338517 Apple MacBook Pro (16-inch, 2019) CVZVJ8R55467 E82C6C63-5F49-4DD3-90A0-E01EC11F6954 Managed https://jamf.pro.server.here/computers.html?id=338517
481915 Apple MacBook Pro (13-inch, M1, 2020) QL6ROPPB1SK5 CBC87B4C-28DA-417F-8790-411AF9F105AD Managed https://jamf.pro.server.here/computers.html?id=481915
596669 Apple MacBook Pro (16-inch, 2021) CNA11CBMJSNI 72811617-8C97-4EB6-BC4B-B9FA9C87B259 Managed https://jamf.pro.server.here/computers.html?id=596669

Viewing all articles
Browse latest Browse all 764

Trending Articles