Forum Discussion
dgillespie-adf
May 14, 2024Brass Contributor
User not found after removing user from SP groups
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:
- why would it remove the user from SP if I am only removing him from SP groups?
- what would be the behavior of the documents he modified if he is removed from SP?
2 Replies
Sort By
- KotiReddyBrass Contributor1. Not sure on this part, I am suspecting user does not have permissions any where eg: indivual permissions any where. If user also removed from individual files where direct permissions assigned then this need to raise with MS.
2. There will be no impact to files which are modified , it is a property get stored in file properties.- dgillespie-adfBrass ContributorThanks for the reply KotiReddy. Looking more at the Remove-SPOUser cmdlet, the official description states, "Removes a user or a security group from a site collection or a group." This is why I ran it, but I am wondering if it also removes a user from the site collection (at least the way I sent the command)?