Getting a count of systems in a computer group

robmorton
Contributor

I am trying to determine which of our policies and profiles are assigned and how. I have a script that pulls all of the API data that I need as CSVs. So now I have a list of them and what they are assigned to, but what I really need is to start tracking down ones that aren't really used anymore. To do that, I would like to get a count of systems that are in the groups. Does anyone have a means of doing a data dump via API or SQL a list of groups and count of systems in those groups.

3 REPLIES 3

seansb
New Contributor III

Just to clarify, are you looking to get a list of all smart / static computer groups and the number of devices within those groups?

robmorton
Contributor

Yeah that is basically it.

seansb
New Contributor III

You'll probably want to do this in two steps:

  1. Query the API to get the id number (or name) of all the computer groups. You can do this by using the API Query: /JSSResource/computergroups . It should return a list of all computer groups listing their name and ID number.

  2. Loop through each ID from the above list and query each computer group independently (via API Query: /JSSResource/computergroups/id/<id number>. What you're looking for is the <size> tag (under the parent tag of <computers>) which will contain the number of computers associated with that group.

Hopefully this helps!