I may have to cleanup the inactive users, so thought of using the 'Remove-SPUser' cmdlet as below.

Remove-SPUser -Identity "demo.net\karthik" -Web http://demo.net/testA/testA1/testA1a -Confirm:$false

What is the negative side of 'Remove-SPUser' in SharePoint 2010?

Quick Observations:

I observed that the user permission is removed from the entire site collection('demo.net') instead of the specific web('testA1a') which is fine in my case.

However, how does it differ from the below?

Get-SPSite "http://demo.net" | Get-SPWeb -Limit All | Remove-SPUser -Identity  "demo.net\karthik"

Also, It removes the user profile from the User information list however it does not affect the existing references(like created by/modified by etc)

  • As far as I verified, it marks the column 'tp_isactive' = 0 on the UserInfo table which says SharePoint that that user account is no longer valid. – Karthikeyan Nov 5 '14 at 18:03
  • It also removes the user permissions by removing the corresponding entry on the table -GroupMembership. – Karthikeyan Nov 5 '14 at 18:10
  • I guess, it works like this, It finds the 'tp_ID' from [UserInfo] table and removes all those entries from the table -[GroupMembership] that are associated with that ID. If so, this is the far easiest way of cleaning up the inactive account. – Karthikeyan Nov 5 '14 at 19:17
  • It would throw errors - Get-SPSite "demo.net" | Get-SPWeb -Limit All | Remove-SPUser -Identity "demo.net\karthik" as Remove-SPUser sets the account disabled at the content DB level. – Karthikeyan Nov 5 '14 at 19:29
  • Just a note: In order to clear the usernames from your site content, you'll have to write a script to crawl all sp webs/lists/items and delete it from there. It should replace the name with SYSTEM\system. Great info though, thanks! – Christopher May 11 '15 at 17:18

Your Answer

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

Browse other questions tagged or ask your own question.