Wednesday, July 29, 2015

SharePoint 2013 TIP: how to remove a user from a site

You have a user that has been directly assigned permissions to a particular site in the site collection. You see this user listed when you go Site Settings > Site permissions. The user has been assigned permission to the site directly and not through membership in any site group.  You want to remove the user from the site but not from the site collection itself.  You don't really want to "remove" the user from the entire site collection.  You need this user to remain a part of the site collection so that when other users click on that username (e.g., associated with a document), they will still see the user properties and not an error page.  So, you don't really want to remove the user from the site using $web.SiteUsers.Remove($user).  What to do?

Solution

  1. Note down the URL of the site you want to remove the user from.
  2. Note down the permission level that the user is (e.g., Read, Contribute, Full Control, etc)
  3. Open an elevated SharePoint Management Shell.
  4. Execute the following:
    Set-SPUser -Identity "[username]" -Web "[URL to the site]" -RemovePermissionLevel "[Permission level]"
  5. That's it.

References

No comments: