SharePoint Online: Delete User from User Information List

Problem: Deleted user accounts still appears in SharePoint Online People Picker! Need to remove user from user information list!

Root Cause: When a SharePoint Online user browse to a site, SharePoint creates an entry in "User information List" to cache the user information. SharePoint syncs this list from user profile when user create/edit/update/delete items. When the user is deleted in Office 365 Azure AD, their related entry in UserInfo list is not removed.

How to Delete User from User Information List in SharePoint Online?
To delete a user from user information list, follow these steps:
This deletes user from user information list in SharePoint Online.We can also Remove user from user information list in SharePoint Online using PowerShell.
Orphaned users are those who doesn't exist in the authentication provider, such as Active Directory, but still be in the "User Information List" and appears in People Picker!

SharePoint Online: PowerShell to Remove User from User Information List
Lets use PowerShell to remove user(s) from user information list in SharePoint Online.
#Import SharePoint Online module
Import-Module Microsoft.Online.SharePoint.Powershell -DisableNameChecking

Function Delete-SPOUser()
{
param
    (
        [Parameter(Mandatory=$true)] [string] $AdminCenterURL,
        [Parameter(Mandatory=$true)] [string] $SiteURL,
        [Parameter(Mandatory=$true)] [string] $UserID       
    )
    Try {
        #Get Credentials to connect
        $Cred = Get-Credential
    
        #Connect to SharePoint online
        Connect-SPOService -Url $AdminCenterURL -Credential $Cred
 
        #Remove user from user information list
        Remove-SPOUser -Site $SiteURL -LoginName $UserID
        Write-host -f Green "Removed the User '$UserID' from $SiteURL"
    }
    Catch {
    write-host -f Red "Error Deleting Orphan Users!" $_.Exception.Message
    }
}

#Set Variables
$AdminCenterURL="https://crescent-admin.sharepoint.com/"
$SiteURL="https://crescent.sharepoint.com/"
$UserID="chauhan.ajay_synechron.com#EXT#@crescent.onmicrosoft.com"

#Call the function to delete the user from user information list
Delete-SPOUser -AdminCenterURL $AdminCenterURL -SiteURL $SiteURL -UserID $UserID

Since the people picker caches search results, you may have to close your current browser sessions, clear cache-cookies for the changes to reflect. Here is my another post to get all orphan users in SharePoint Online and delete them: SharePoint Online: Find and Delete Orphaned users using PowerShell
SharePoint Online: Delete User from User Information List SharePoint Online: Delete User from User Information List Reviewed by Salaudeen Rajack on February 04, 2018 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.