Replace the membership of a user in a Microsoft Group or Microsoft Team
The CLI for Microsoft 365 is a cross-platform command-line interface used to manage or automate Microsoft 365 resources. It is a PnP and community-driven initiative that is growing rapidly over time.
This script can help in replacing the membership of an existing user with the permissions of a different one. You could think about a person that changes role or leaves the company. The script is inspired from this blogpost. The script uses the CLI for Microsoft 365 to perform all activities.