While in the process of re-writing some provisioning code I needed a quick way to verify whether a user was a member of a group or combination of groups. I ended up writing the function below that's wrapped up in my function template (read snippet). That said, looking past the search and uniqueness verification the actual code is quite simple. When run it outputs either True or False. I've ended up putting the command and related parameters in varying if statements.
Just another tool for the toolbox.