Check If A Group Exists on Macbook

ferriterj1
New Contributor III

Hey!

I was wondering if there was a way to check if a group existed on a MacBook?

Like :

If [Group exists]

then ( do this)

else (do nothing)

Is there any quick and easy way to perform this? My scripting skills are still developing so I appreciate any and all help!

1 ACCEPTED SOLUTION

mm2270
Legendary Contributor II

Oh, ok. In that case, there are a few ways.

dscl . list /Groups

The above would list all local groups on the device. You can throw on a grep at the end to look for specific ones if needed.

You can also get details on any group if needed with dscl, but you can also do it with dseditgroup For example:

dseditgroup -o read admin

Or using dscl:

dscl . read /Groups/admin

Does that help?

View solution in original post

4 REPLIES 4

mm2270
Legendary Contributor II

What kind of group are you referring to? Do you mean a Smart Group in Jamf or something else?

ferriterj1
New Contributor III

A group on the MacBook itself. Like an admin group or a created group.

mm2270
Legendary Contributor II

Oh, ok. In that case, there are a few ways.

dscl . list /Groups

The above would list all local groups on the device. You can throw on a grep at the end to look for specific ones if needed.

You can also get details on any group if needed with dscl, but you can also do it with dseditgroup For example:

dseditgroup -o read admin

Or using dscl:

dscl . read /Groups/admin

Does that help?

View solution in original post

ferriterj1
New Contributor III

Perfect! Just what I needed!

Thank you!