Obtaining all users of a group with a script

This article demonstrates a script that can collect all the users of a certain group and write them to a variable.
 
Note
There are three types of elements that a group can include:
1) Users
2) Organizational Structure elements assigned to the users 
3) Other groups that may contain users, organizational structure elements, and groups.
In this case by "users of a group" we imply the first type, Users.

Script with PublicAPI

Note
Documentation on PublicAPI is available here
Attention
The script below is relevant for ELMA up to 3.12.1 inclusive.

Context variable:

context.Users - Users, User type variable, link type - List 

Namespace:

using EleWise.ELMA.API;

Script text:

var grp = PublicAPI.Portal.Security.UserGroup.Filter().SearchString("All users").Find().First().Users.ToList();
foreach (var item in grp)
{
    context.Users.Add(item);
}

Script without PublicAPI

The script uses the following context variable:

context.Users - Users, User type variable, link type - List 

You need the following namespaces:

using EleWise.ELMA.Security.Models;
using EleWise.ELMA.Security.Managers;

Script text:

var filter=new UserGroupFilter();
filter.ShowOnlyGroups=true; //search by groups
filter.SearchString="All users"; //specify group name for search
var grp=UserGroupManager.Instance.Find(filter,null);
foreach(var item in grp.First().Users.ToList()) 
        {
            var user=(User)item;
            context.Users.Add(user);
        }