Learn how to Remove User from User Information List in SharePoint Online
The user information list acts as a centralized location to store the user details. It saves the user’s information when accessing the SharePoint list, sites, or document library to cache the information. But on-boarding and off-boarding are regular tasks in organizations due to which user’s information gets deleted regularly. However, deleting the user from Azure AD is not enough to clear all the records of the past employee. The user information list still stores the user details. Most of the SharePoint administrators are still unaware of how to remove user from user information list in SharePoint Online.
Table of Content
Therefore in this article, we will discuss the different methods to delete user details from the user information list.
How to Delete User from User Information List in SharePoint?
The deletion of user entries from the user information list is different from removing them in Azure AD. The user details even after deletion affect the SharePoint performance or increase complexities in SharePoint tenant to tenant migration.
You can delete the user information from SharePoint using two different methods. Let’s discuss them in detail. But before going to discuss methods, let’s find the list of all users from the SharePoint information list.
Generate Report of All Users from SharePoint Information List
Execute the below code to get a clear picture of all users before going to delete them.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.SharePoint; using Microsoft.SharePoint.Administration; using System.IO; namespace UserInformationListReport { class Program { static void Main(string[] args) { string SP_site; string Email_ID=string.Empty; string User_Name = string.Empty; try { if (args.Length == 0) { Console.WriteLine("Enter the Web Application URL:"); SP_site = Console.ReadLine(); } else { SP_site = args[0]; } StreamWriter SPOW; SPOW = File.AppendText("c:\\UserInfoListReport.csv"); SPOW.WriteLine("Name of Site collection, URL, Account, User Name to remove, E-Mail address"); SPSite tmp_Root = new SPSite(SP_site); SPSiteCollection oSPSiteCollection = tmp_Root.WebApplication.Sites; foreach (SPSite oSPSite in oSPSiteCollection) { SPWeb oSPWeb = oSPSite.OpenWeb(); SPList oSPList = oSPWeb.SP_SiteUserInfoList; foreach (SPItem oSPItem in oSPList.Items) { try { Email_ID = oSPItem["Work e-mail"].ToString(); User_Name = oSPItem["User name"].ToString(); } catch (Exception ex2) { Email_ID=string.Empty; User_Name = string.Empty; } SPOW.WriteLine(oSPWeb.Title.Replace(",", " ") + "," + oSPSite.Url + "," + oSPItem["Account"] + "," + User_Name+ "," + Email_ID); } } Console.WriteLine("Enter a key to exit"); Console.ReadLine(); SPOW.Close(); } catch (Exception delete_error) { System.Diagnostics.EventLog.WriteEntry("Users Information List Report is", delete_error.Message); } } } }
Also Read: Why SharePoint List not showing all items?
How to Remove User from User Information List in SharePoint Online Using Admin Center?
You can use the below steps using the Admin Center to delete the user from the user information list completely.
- Step 1. Sign in to SharePoint Admin Center using the right credentials.
- Step 2. Move to the People and Groups.
- Step 3. Open the All People section.
- Step 4. Tick the checkboxes of the users to delete and hit the Actions option.
- Step 5. Now, choose Delete Users from the Site Collection.
- Step 6. Confirm the opened prompt to remove the selected users from the SharePoint user list.
Delete User from User Information List in SharePoint Using PowerShell
PowerShell commands to remove user from user information list. Go with the below commands only if you have expertise in PowerShell to get the expected results.
Import-Module Microsoft.Online.SharePoint.Powershell -DisableNameChecking Function Delete-SPOUser_List() { param ( [Parameter(Mandatory=$true)] [string] $Admin_SP_URL, [Parameter(Mandatory=$true)] [string] $Site_URL, [Parameter(Mandatory=$true)] [string] $User_ID ) Try { $Cred = Get-Credential Connect-SPOService -Url $Admin_SP_URL -Credential $Cred Remove-SPOUser -Site $Site_URL -LoginName $User_ID Write-host -f Green "Removed the User '$User_ID' from $Site_URL" } Catch { write-host -f Red "Error in Deleting the Users from the Users Information List!" $_.Exception.Message } } $Admin_SP_URL="enter the correct URL" $Site_URL="Provide the Site URL" $User_ID="add the ID of the user" Delete-SPOUser_List -Admin-SP_URL $Admin_SP_URL -Site_URL $Site_URL -User_ID $User_ID
PnP PowerShell to Remove User from User Information List in SharePoint Online
Execute the below PnP PowerShell script to delete the user’s entries permanently from the user information list.
$SPO_Site_URL = "enter site’s URL" $User_ID = “Enter User ID to delete from the user information list" Connect-PnPOnline -Url $SPO_Site_URL -Interactive $user_To_Remove = Get-PnPUser | Where { $_.Email -eq $User_ID} if ($User_To_Remove -ne $null) { Remove-PnPUser -Identity $User_To_Remove.Id -Force Write-Host -f "Specified User has been removed successfully." } else { Write-Host -f "Requested User is not found in the SharePoint List." }
Final Words
In this detailed article, we have discussed the numerous methods to remove user from user information list in SharePoint Online. You can choose method as per your expertise. If you have expertise in PowerShell then you can use the above-explained script. Otherwise, use the Admin Center steps for easy deletion of users from the user information list.