Skip to content

update_static_group_from_csv

Chris Lasell edited this page Aug 28, 2023 · 1 revision

This will set the membership of a static computer group from the computer names contained in a local CSV file

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://[email protected]'

# 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
Clone this wiki locally