ninxsoft / Kmart

A Mac command-line tool that generates kick-ass Jamf Pro reports.
MIT License
136 stars 10 forks source link

Nested Smart Groups #22

Closed feolaney closed 1 year ago

feolaney commented 1 year ago

Smart Groups that are nested in other Smart groups show up as not being linked to any Policies.

Jamf (depending on your version) will prohibit the deletion of groups that have other Smart Groups dependent on them. For these reports though, it makes it seem like certain smart groups are unused or not scoped when in actuality they can be by association with the parent Smart Group

ninxsoft commented 1 year ago

Makes sense, will look into adding this functionality!

Thanks!

ninxsoft commented 1 year ago

This has been fixed in ef67d8835844e6c79baba1afbb4b95e46827ad15

grahampugh commented 1 year ago

This is great news! Just curious; how many iterations does it go through to look for nesting? In my internal scripts I go three-deep, because I didn't find any instances where there were groups more nested than that.

ninxsoft commented 1 year ago

Hi @grahampugh!

My implementation is quite naive: I am looking for Computer Groups or Mobile Device Groups where the value is a "member of" a particular Smart Group. Anything that matches is deemed linked / in-use.

Example where all Smart Groups are linked / in-use (more or less the same as my unit tests):

Example where Smart Groups 1 and 2 are linked / in-use, and Smart Group 3 is not linked / in-use:

So in answer to to your question, 1 level deep? Am I missing some additional criteria / steps that I should be testing against?

Happy to be schooled educated by someone that might use Jamf Pro more than I do these days 😃

grahampugh commented 1 year ago

Ah, actually thinking about it, of course that's enough for finding unused groups. I was thinking about the scripts that I wrote for copying a group or policy to a new Jamf instance with all its dependencies - completely different thing! Sorry, pre-coffee nonsense.