Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

share|improve this question
    
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
add comment

2 Answers

up vote 2 down vote accepted

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 .

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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