Skip to content

JNUC2019 Lab Session H Adding to Groups

Chris Lasell edited this page Oct 21, 2019 · 7 revisions

Hands On, Real-time Classic API Using ruby-jss

(Home)

Lab Session Contents - 7 - Adding to a Group

Previous           TOC           Next

  • Now we can add the computers we just created to the static group we just created!

  • There are a couple of ways to add and remove members from static groups

  • The original way is to add them individually by name or id

    • then save the group back to the JSS
    • We'll do that later in a script.
  • The change_membership method is a little different from most methods that change objects.

    • It uses the ability of the API to add and remove group members directly and immediately
my_grp.change_membership add_members: new_comp_ids
# => array of member data
  • the add_members: parameter takes an Array of any kind of identifiers; ids, names, serialnumbers, udids, etc

    • We already have an array of the ids of our computers: new_comp_ids
  • There's no need to use save after using change_membership

    • the changes are immediately applied to the JSS
  • You can also provide a remove_members: parameter to add and remove at the same time.

  • you will get an error if you try to add something that doesn't exist in the JSS

Previous           TOC           Next

Clone this wiki locally