Most of our Enterprise customers are using a directory service called: Active-Directory, provided by Microsoft. This directory service is often structured in logical groups of objects (computers, users, devices). Especially the users are also organized in organizational units (OUs) within the active directory. With having several thousand users, organized in this fashion, some of our customers wants to add specific groups to Mattermost channels before they even joined.

Mattermost allows the bulk import of data into the server with a bulk_import tool which is part of the central platform command. The detail can be found here:

The tool needs the data to be imported in a JSONL (JSON lines) format which can´t be created out of the box on a Windows Active-Directory server. A PowerShell script seems to be the best option here. I wrote the following script which can be easily used and forked:



There are different important lines that can be changed to solve your use-case. First thing is the search base which can be easily pointed to another OU or CN. The other thing to check is the search filter as you may just want to add specific user to specific channels, like all HR user to the “Onboarding” and “Interviews” channel. Right now the script is written to support one team and many channels which can be changed by adding another loop inside.

The result of the script is a JSONL file that can be used by the bulk import command on the Mattermost server. Please use the –validate switch before uploading the users and keep in mind that the channel names have to be lowercase on the PowerShell import!



When all users are imported they should be already part of the channels you’ve added them with the script and import (testchannel, secondone).