Skip to main content
Solved

Check If A Group Exists on Macbook

  • December 5, 2018
  • 4 replies
  • 50 views

Forum|alt.badge.img+6

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!

Best answer by mm2270

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?

4 replies

mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • December 5, 2018

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


Forum|alt.badge.img+6
  • Author
  • Contributor
  • December 5, 2018

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


mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • Answer
  • December 5, 2018

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?


Forum|alt.badge.img+6
  • Author
  • Contributor
  • January 3, 2019

Perfect! Just what I needed!

Thank you!