@dashrender You used $group but did not define it in your first example.
it's not defined on purpose - several of these have undefined, it's expected that you will define/replace them yourself.
That is a very poor guide. You posted a script. I expect to copy and paste it and see something work.
Jared is right to a point.
I've now gone back and added variables to all of my scripts making it easier for someone using these to see that they need to enter their own information into the variables to make it work.
I could take it a step further and prompt for that data - but one thing at a time.