Ensure a group contains only the members in the list

    Args:

        name (str):
            The name of the group to modify

        members_list (str):
            A single user or a comma separated list of users. The group will
            contain only the users specified in this list.

    Returns:
        bool: ``True`` if successful, otherwise ``False``

    CLI Example:

    .. code-block:: bash

        salt '*' group.members foo 'user1,user2,user3'

def members(name, members_list, **kwargs):
    '''
    Ensure a group contains only the members in the list

    Args:

        name (str):
            The name of the group to modify

        members_list (str):
            A single user or a comma separated list of users. The group will
            contain only the users specified in this list.

    Returns:
        bool: ``True`` if successful, otherwise ``False``

    CLI Example:

    .. code-block:: bash

        salt '*' group.members foo 'user1,user2,user3'
    '''
    members_list = [salt.utils.win_functions.get_sam_name(m) for m in members_list.split(",")]
    if not isinstance(members_list, list):
        log.debug('member_list is not a list')
        return False

    try:
        obj_group = _get_group_object(name)
    except pywintypes.com_error as exc:
        # Group probably doesn't exist, but we'll log the error
        msg = 'Failed to access group {0}. {1}'.format(
            name, win32api.FormatMessage(exc.excepinfo[5]))
        log.error(msg)
        return False

    existing_members = [_get_username(x) for x in obj_group.members()]
    existing_members.sort()
    members_list.sort()

    if existing_members == members_list:
        log.info('%s membership is correct', name)
        return True

    # add users
    success = True
    for member in members_list:
        if member not in existing_members:
            try:
                obj_group.Add('WinNT://' + member.replace('\\', '/'))
                log.info('User added: %s', member)
            except pywintypes.com_error as exc:
                msg = 'Failed to add {0} to {1}. {2}'.format(
                    member, name, win32api.FormatMessage(exc.excepinfo[5]))
                log.error(msg)
                success = False

    # remove users not in members_list
    for member in existing_members:
        if member not in members_list:
            try:
                obj_group.Remove('WinNT://' + member.replace('\\', '/'))
                log.info('User removed: %s', member)
            except pywintypes.com_error as exc:
                msg = 'Failed to remove {0} from {1}. {2}'.format(
                    member, name, win32api.FormatMessage(exc.excepinfo[5]))
                log.error(msg)
                success = False

    return success