1

I am looking for some help removing a User Permission from a site using PowerShell.

  • Thanks for the replies. My apologies for not realizing this question was never marked answered. To clarify the question: I was referring to removing a "User Permission" not an SPUser object from the site. – ChiliYago May 13 '13 at 17:55
  • Do mean in the sense of "Contribute", "Read" etc.... – BlueBird Jul 31 '13 at 12:34
  • remove the user from the site this seems to remove the users from any groups, webs, and list and item permissions! – user21509 Dec 18 '13 at 22:52
4

To remove site permissions for a user, you will have to remove the user from the group to which the user has been given permission to. Sample code would look like this -

$site = new-object Microsoft.SharePoint.SPSite("Site URL") 
$web = $site.OpenWeb() 
$oSiteGroup = $web.SiteGroups["Group Name"];
$oUsers = $oSiteGroup.Users
foreach ($oUser in $oUsers) 
{ 
    "Removing user : " + $oUser.Name 
    $oSiteGroup.RemoveUser($oUser) 
}

If the user is given permission directly without being added in a gorup, rewrite the above code, search within $web.users instead of $oSiteGroup.Users and it should work.

Good Luck .

0

Have a look here for an example

http://blogs.visigo.com/chriscoulson/bulk-delete-sharepoint-site-users-with-powershell/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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