In this article, I am going to explain how to add remove bulk users to Microsoft Teams team or Microsoft 365 group using CLI for Microsoft 365 and PowerShell Script.
What is CLI for Microsoft 365?
CLI for Microsoft 365 is an open-source project driven by the SharePoint Patterns and Practices initiative. The project is built and managed publicly on GitHub and accepts community contributions.
How can contribute to CLI for Microsoft 365 open-source project?
CLI for Microsoft 365 open-source project has a number of feature requests that are a good starting point to contribute to the project.
Why should I contribute to CLI for Microsoft 365?
You may have different individual motivations but working on @office365cli improves coding skills, gain early experience, recognition and chance to work with top class developers around the globe.
How to install the CLI for Microsoft 365?
CLI for Microsoft 365 is distributed as a Node.js package and published on npmjs.com. You can install it using your Node package manager, such as npm or Yarn.
To install the CLI for Microsoft 365, in the command line execute:
npm install -g @pnp/office365-cli
What are all the commands used from CLI for Microsoft 365 in this sample code?
- Lists Office 365 Groups in the current tenant
- Gets information about the specified user
- Adds user to specified Office 365 Group or Microsoft Teams team
- Removes the specified user from specified Office 365 Group or Microsoft Teams team
Companies pursue to hasten profits growth or enter new marketplace through Mergers and Acquisitions(M&A). M&A typically fails during integration. This also applies to migrating users and data in Microsoft Teams and Groups. Partial acquisition can be pretty tricky. To help make the activity as charming as possible, I have created the following sample script to add/remove bulk users to/from Microsoft Teams team or Microsoft 365 group using CLI for Microsoft 365 commands.
Note: Refactor the code as per your requirement.
Input CSV File Format
I hope you find this post helpful. Let me know your thoughts in the comments section.
Photo by Manasa Muthyala