I tried following commands:
PS >$u = Get-SPOUser -Site "https://removed.sharepoint.com/sites/1" | Where-Object {$_.LoginName -like 'spo-grid-all-users/*'}
PS >Remove-SPOUser -Site "https://removed.sharepoint.com/sites/1" -LoginName $u.LoginName
This fails with following error:
Remove-SPOUser : Cannot complete this action.Please try again.
At line:1 char:1
+ Remove-SPOUser -Site "https://removed.sharepoint.com/sites/1" -LoginNam ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Remove-SPOUser], ServerException
+ FullyQualifiedErrorId : Microsoft.SharePoint.Client.ServerException,Microsoft.Online.SharePoint.PowerShell.RemoveSPOUser
Removing from the group does not work either:
PS >Remove-SPOUser -Site "https://removed.sharepoint.com/sites/1" -LoginName $u.LoginName -Group "1 Members"
Remove-SPOUser : The user does not exist or is not unique.
At line:1 char:1
+ Remove-SPOUser -Site "https://removed.sharepoint.com/sites/1" -LoginNam ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Remove-SPOUser], ServerException
+ FullyQualifiedErrorId : Microsoft.SharePoint.Client.ServerException,Microsoft.Online.SharePoint.PowerShell.RemoveSPOUser
I can remove Everyone except external users group from site and Members group here https://removed.sharepoint.com/sites/1/_layouts/15/people.aspx page with the same creds that I'm using in the PowerShell session.