You have a couple thousand users you need to remove from a specific channel.
- Get a list of the user’s email addresses, usernames, or user IDs in a text file, with one entry per line named
users.txt. For example:
email@example.com firstname.lastname@example.org email@example.com
- Create this shell script and give it the name
#!/bin/bash mattermost_cmd=$1 $ids_file=$2 while read id; do /opt/mattermost/bin/mattermost $mattermost_cmd $id; done <$ids_file
- Run the shell script with the Mattermost CLI command as the first argument and the text file as the second argument. For example:
$ ./mattermost_process_file.sh "channel remove teamname:channelname" users.txt
This is a really common problem for Mattermost administrators, and bash’s great scripting functionality solves it very easily. This works for any Mattermost CLI command that accepts an identifier as the final argument, such as
team add, or
If you have any feedback or specific questions about how to use this script please let me know!