How to Remove a User from all Office 365 Groups using PowerShell
If you need to remove a user from all Office 365 Groups, you can do this quickly via PowerShell, which will also allow you to automate the process.
The method demonstrated here shows how this is accomplished using the Get-AzureADMSGroup cmdlet to grab all of the Office 365 Groups in the tenant. These groups can then be searched to identify whether the user in question is a member or owner of the group, and if so, remove them. It should be noted that an Office 365 Group must have an owner. Therefore, if we are removing the sole owner of a group, we must first add another owner.
This method makes use of the AzureAD module and the Get-AzureADMSGroup cmdlet. This is much faster at retrieving all Office 365 Groups in comparison to the Get-UnifiedGroup cmdlet in Exchange Online.
Prerequisites include: AzureAD Module installed Connect-AzureAD