Hello @Ricardo Soares Teixeira
Thank you for reaching out. You can use following PowerShell Script to remove all users from Azure AD Groups.
Connect-AzureAD
$GroupObjectID= Read-Host -Prompt "Enter Group Object ID from which you would like to remove all the members"
$GroupName = Get-AzureADGroup -ObjectId $GroupObjectID | Select-Object -ExpandProperty DisplayName
Write-Host "Group you entered is $GroupName"
$Memberlist = Get-AzureADGroupMember -ObjectId $GroupObjectID -All $true
foreach ($user in $Memberlist)
{
Remove-AzureADGroupMember -ObjectId $GroupObjectID -MemberId $user.ObjectId
Write-host "Removed user account "$user.DisplayName" from group "$GroupName""
}
Sample Output:
I hope this helps and fixes your issue. Please "Accept the answer" if the information helped you. This will help us and others in the community as well.