Thank you @jericson, this is exactly what I was looking for.
I am guessing that I could feed the results to a query that adds all users to a group then.
Is there anyone that have had experience doing that? Maybe it’s better to brutally copy-paste the user ids and run a ruby function if there is something available?