Skip to main content

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!

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


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


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?


Perfect! Just what I needed!



Thank you!