Thursday, 16 October 2014

How to list and remove orphaned users in SharePoint 2013 using powershell

First run the following script to get a list of the users and what their access is:
$urlWeb = "WebUrl"
Get-SPUser -Web $urlWeb | select UserLogin, @{name=”Exlicit given roles”;expression={$_.Roles}}, @{name=”Roles given via groups”;expression={$_.Groups | %{$_.Roles}}},Groups | format-Table -auto

Then Run the following to remove individual user permissions. This is handy if you have migrated from a test environment using FBA and the existing accounts dont exists in your production FBA user store. NOTE: you substitute the following ProviderNames based on the claims auth type you are using. i:0#.f|FBAProviderName | i:0#.w|windowsProviderName | WindowsDomain\UserName
PS E:\> Remove-SPUser -identity "i:0#.f|ProviderName|vand" -web WebUrl

No comments:

Post a Comment