SharePoint Online: Delete User from User Information List
Problem: Deleted user accounts still appear in SharePoint Online People Picker! We need to remove the user from the user information list!
Root Cause: When a SharePoint Online user browses a site, SharePoint creates an entry in the “User Information List” to cache the user information. SharePoint syncs this list from the user profile when the user create/edit/update/delete items. When the user is deleted in Office 365 Azure AD, their related entry in the UserInfo list is not removed.
How to Delete User from User Information List in SharePoint Online?
In SharePoint Online, the user information list is a central repository that stores information about all users who have accessed the site. This is a hidden list used to track user activity and to provide additional information about users, such as their name, email address, and other profile information. However, there may be times when you need to remove a user from the user information list, such as when a user has left the organization or when there is inaccurate or outdated information. In this article, we will discuss how to remove a user from the user information list in SharePoint Online.
To remove a user from the user information list, follow these steps:
- Navigate to the URL in the browser: https://YourDomain.sharepoint.com/_layouts/15/people.aspx?membershipGroupId=0
- This takes you to the “All People” View. You can now select and remove users from this User Information List by Clicking on Actions >> Delete User from Site Collection and then confirming the prompt.
This deletes the user from the user information list in SharePoint Online. We can also remove users from the user information list in SharePoint Online using PowerShell.
SharePoint Online: PowerShell to Remove User from User Information List
Let’s use PowerShell to remove the user(s) from the 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
The user should now be removed from the user information list in SharePoint Online. Since the people picker caches search results, you may have to close your current browser sessions to clear the cache and cookies for the changes to reflect.
PnP PowerShell to Delete User from this User Info List
Use this PnP PowerShell script to completely remove the user from the site and User Info list:
Remove-PnPUser -Identity i:0#.f|membership|user@domain.com -Confirm:$false
Replace the User@Domain.com accordingly! I assume you have PnP PowerShell installed on your machine! Here is the complete script:
#Config Variables
$SiteURL = "https://crescent.sharepoint.com/sites/Retail"
$UserID = "PattiF@crescent.com"
# Connect to the SharePoint site
Connect-PnPOnline -Url $SiteURL -Interactive
$userToRemove = Get-PnPUser | Where { $_.Email -eq $UserID}
# Check if user exists
if ($UserToRemove -ne $null) {
# Remove the user
Remove-PnPUser -Identity $UserToRemove.Id -Force
Write-Host -f Green "User removed successfully."
} else {
Write-Host -f Yellow "User not found."
}
This script does the following:
- Connects to your SharePoint site.
- Searches for the user with the specified email address.
- If the user is found, it removes them from the SharePoint site, which will reflect in the User Information List.
Wrapping up
By following the steps outlined above, you can easily remove a user from the user information list in SharePoint Online. By removing a user from the user information list in SharePoint Online, you can ensure that the site user list is accurate and up-to-date, and that it is not cluttered with outdated or unnecessary information. It is important to note that removing a user from the user information list may have an impact on other areas of SharePoint, such as audit logs and workflow history. If you need to preserve this information, it is recommended that you disable or delete the user’s account instead of removing them from the user information list.
Here is another post to get all orphan users in SharePoint Online and delete them: SharePoint Online: Find and Delete Orphaned Users using PowerShell
Seriously how is this even a thing. Shouldn’t Microsoft treat this as an incident and fix it in their backend?