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