Hi All,
Is there a jamf command that will automatically scope a machine to a certain policy?
Thanks in advance.
Hi All,
Is there a jamf command that will automatically scope a machine to a certain policy?
Thanks in advance.
Best answer by seraphina
So what you will want to do is something like the following :
the keys you want to change are
<computer_group_memberships>
<group>All Managed Clients</group>
<group>On Campus</group>
<group>Faculty+Staff Machines</group> <!-- static group -->
<group>Faculty/Staff Machines</group> <!-- smart group based on DEP or membership of the static -->
<group>Laptops</group>
<group>Machines on Mojave or above</group>
</computer_group_memberships>
Step 1: Pull Computer Record
Step 2: Edit the XML response, adding the group you want the computer to be a part of.
Step 3: POST the Computer Record to the appropriate ID
#!/bin/bash
jssUser="$4"
jssPass="$5"
jssURL=$(/usr/bin/defaults read /Library/Preferences/com.jamfsoftware.jamf.plist jss_url | /usr/bin/sed s'/.$//'_)
udid=$(/usr/sbin/system_profiler SPHardwareDataType | /usr/bin/awk '/UUID/ { print $3; }') #use UUID over Serial #, that way each computer has a UNIQUE UUID. If a motherboard gets replaced, the UUID changes, but the SN is the same
/usr/bin/curl -X GET --user "$jssUser:$jssPass" "$jssURL/JSSResource/computers/udid/$udid" | /usr/bin/xmllint --format - >> /var/tmp/record.xml
Programmatically make the changes to your user group, then PUT
the updated record (POST
will overwrite the record entirely, PUT
will change a desired part.. You may need to play with this on a non production machine). You need to do xmllint
because the cURL response will be 1 giant line and will mess up with things like sed
. Alternatively however, you should lookin to --xpath
with xmllint
curl -X PUT --user "$jssUser:$jssPass" --data "@/path/to/file" "$jssURL/JSSResource/computers/udid/$udid"
Of course you can probably do this without a GET command at all, and just PUT what you need in the computer record, but again you should play around first before trying to get the API calls working in production.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.