May 14 2024 10:43 AM
First thing I did was list all the SP groups a user was a member of via Powershell by running:
Get-SPOUser -Site https://xxxx.sharepoint.com -LoginName email address removed for privacy reasons | Select-Object -ExpandProperty Groups | FL *
This spit out a list that included groups and sharing links and look something like:
SharingLinks.xxxxxxxx.OrganizationView.aca4629b-2156-466f-be31-eead2188db4e
SharingLinks.xxxxxxxx.Flexible.630dde56-f7ca-47bd-86bb-c26dbba1a903
SharingLinks.xxxxxxxx.OrganizationView.04dd59e4-7cae-4290-aff0-477af7626f26
Facilities Management Members
So I ran these commands to define the user and groups:
$user = Get-SPOUser -Site https://xxxx.sharepoint.com -LoginName email address removed for privacy reasons
$userGroups = Get-SPOUser -Site https://xxxx.sharepoint.com -LoginName $userLoginName | Select-Object -ExpandProperty Groups
And then I ran this command to remove him from the groups:
foreach ($group in $userGroups) {
Remove-SPOUser -Site https://xxxx.sharepoint.com -LoginName $userLoginName -Group $group.Title
Write-Host "Removed user $userLoginName from group $($group.Title)"
}
This took a long time and I suspect it removed the user from all the sharing links too. Now when I run the Get-SPOuser command, I get the error:
Get-SPOUser : User cannot be found.
At line:1 char:1
+ Get-SPOUser -Site https://xxxx.sharepoint.com -LoginName users@co...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-SPOUser], ServerException
+ FullyQualifiedErrorId : Microsoft.SharePoint.Client.ServerException,Microsoft.Online.SharePoint.PowerShell.GetSPOUser
So my questions are:
May 15 2024 08:19 AM
May 15 2024 08:46 AM