Skip to main content
Solved

Jamf Pro API - Bulk ADD and Remove computers from static group assignments


Forum|alt.badge.img+6

I am new to Jamf Pro API and I am diving into more and more automations. 

 

Can someone help me with how i would go about to updating multiple computer assignments for a static group by using computer names. If you have a working script, please assist. maybe via csv file?

Best answer by talkingmoose

You may want to use The MUT found in the Mac App Store. Requires no scripting knowledge.

https://apps.apple.com/us/app/mut/id1133234759?mt=12

View original
Did this topic help you find an answer to your question?

3 replies

talkingmoose
Forum|alt.badge.img+36
  • Community Manager
  • 1900 replies
  • Answer
  • August 26, 2023

You may want to use The MUT found in the Mac App Store. Requires no scripting knowledge.

https://apps.apple.com/us/app/mut/id1133234759?mt=12


Forum|alt.badge.img+13
  • Contributor
  • 15 replies
  • August 28, 2023

If you still want a scripted solution, and you are familiar with, or willing to use, ruby as your programming language, ruby-jss makes doing things like this very easy: 

 

#!/usr/bin/env ruby
require 'ruby-jss'
require 'csv'

# This csv file contains the computers that should be in the group
# Computer names are in the first field of this csv file.
# Get the names into an array

desired_comp_names = CSV.read('/path/to/computernames.csv').map(&:first)

# connect to Jamf Pro
# you'll be prompted for the password, or it can be given with the 'connect' command

Jamf.connect 'https://apiuser@myjamfhost.jamfcloud.com'

# get the group by name

static_group = Jamf::ComputerGroup.fetch name: 'StaticGroupName'

# replace any existing membership with the desired names

static_group.members = desired_comp_names

# save your changes

static_group.save

Five lines of code, not counting the shebang and 'require' lines.


adonboli
Forum|alt.badge.img+6
  • New Contributor
  • 16 replies
  • September 8, 2023
talkingmoose wrote:

You may want to use The MUT found in the Mac App Store. Requires no scripting knowledge.

https://apps.apple.com/us/app/mut/id1133234759?mt=12


Been using MUT for a few years now, very happy with it, though I always get the "need to use classic method" verbiage and if I want to run it that way and I always say yes. 

Kinda wish, I could make that the default, but either way, great program. 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings