0

Following is my command : Remove-SPUser -Identity 'i:0#.w|sp13\TestUser' -Web 'http://spserver-sp13/sites/TesSite' -Group 'Testme11' -Confirm:$False

Here group Testme11 is a group without permission, when I execute above command from powershell, sharepoint server removes the user from the above mentioned group as well other groups (groups with permission) that user is part of.

But when we use above command for removing a user from a group with permission, it just removes it from the intended group.

hence please let me know if this is a bug ?

1 Answer 1

1

You could use the following command to remove the user from specific group:

$web=Get-SPWeb http://spserver-sp13/sites/TesSite
$group=$web.groups["Testme11"]
Remove-SPUser -Identity 'i:0#.w|sp13\TestUser' -Web $web -Group $group -Confirm:$False
5
  • but my command works as expected when i use a group with permissions, why does it weirdly remove user from every group when a group without permissions is present in the command. Commented Jun 12, 2019 at 10:20
  • Per my test, I find that group without permission in SharePoint would not exist in powershell. When use $web.groups command, you would not find the group without permission. So I guess in your command, it would remove the users from this site because it cannot find this group. Commented Jun 13, 2019 at 9:09
  • Thanks a lot Michael for your explanation! Commented Jun 17, 2019 at 6:20
  • Please accept it as answer if it helps you. Commented Jun 17, 2019 at 6:23
  • Hi Michael, Please can you let me know on how can i utilize the $web in c# application Commented Jun 21, 2019 at 5:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.