In this “Hide Disable or Inactive Users From SharePoint Online Search” article, we will learn how to hide disabled or inactive users from SharePoint Online search results. When an employee leaves the organization, those employees are still shown on the search result page even though they are disabled or inactive. In this case, we want to hide disabled or inactive users from SharePoint online searches. How do we handle this? In this article, I will explain how to implement this.
Description: Hide disable or inactive users from SharePoint online search
When some users already have left the origination, but those users continue to appear in the SharePoint search result in this scenario we have to hide the disabled inactive users from the below SharePoint online search page, what is the approach to implementing this?
1. https://sp.sharepoint.com/search/Pages/peopleresults.aspx
2. https://sp.sharepoint.com/sites/sales/_layouts/15/search.aspx
Resolution: Hide disable or inactive users from SharePoint online search
We need to follow the below steps to hide the inactive users from SharePoint Online search result
Step 1:
Get all disabled users from your local AD using the below PowerShell command and export to CSV.
Get-ADUser -Filter {Enabled -eq $false} | FT samAccountName, GivenName, Surname
Or
Get-ADUser -Filter {Enabled -eq $false} | select SamAccountName, GivenName, Department, Location | Export-Csv "C:\temp\ADDisabledUsers.csv"
Step 2:
Need to change the profiles AD property “msExchHideFromAddressLists” to True or Yes for all disabled users got in step 1
set-adobject -Identity $someoneDisabledUser -replace @{msexchhidefromaddresslists="$true"}
Notes:
The best way to update in bulk if we have more disabled users is as below:
- Export to CSV all disabled users using the above step 1 command.
- Read the csv – and inside foreach loop call the set-adobject -Identity $someoneDisabledUser -replace @{msexchhidefromaddresslists=”$true”}
Example:
$disabledUsersCSV=Import-Csv "C:\temp\ADDisabledUsers.csv"
foreach($oneDisabledUser in $disabledUsersCSV)
{
$disabledUser=$oneDisabledUser.SamAccountName
set-adobject -Identity $disabledUser -replace @{msexchhidefromaddresslists="$true"}
}
Step 3:
Update the search query as below on the SharePoint search query page:
- Go to the enterprise search people results on page: https:///search/Pages/peopleresults.aspx Example: https://globalsharepoint.sharepoint.com/search/Pages/peopleresults.aspx
- Edit Search Results page
- Edit the People Results Web Part
- Change query
- Change Query Text from {searchboxquery} to {searchboxquery} AND -“SPS-HideFromAddressLists”:1
Outcome:
All disabled users will not be shown in the search.
Notes:
- Changing the “MailNickName” attribute in on-premise AD is a must, without this attribute change the “msExchHideFromAddressLists” attribute will not be synced to SharePoint online.
- This technique will not work – if the users are created in the cloud.
- So Microsoft needs to change the below “May” to “Must” in the below document:
“Hint: You may (should be a must) need to add/update the “MailNickName” attribute in on-prem AD for the msExchHideFromAddressLists to sync. ”
It is worth knowing how search works in SharePoint Online.
How does SharePoint Online Search work?
SharePoint Online Search is a robust search engine integrated into Microsoft’s SharePoint Online platform, a cloud-based collaboration and document management system. It helps users find the information they need within the vast repositories of data hosted on SharePoint Online. The search functionality in SharePoint Online is powerful and highly customizable, providing users with relevant and accurate results based on their queries.
Here’s an overview of how SharePoint Online Search works:
- Content Crawling and Indexing: SharePoint Online Search begins with content crawling and indexing. The search engine continuously scans the content within SharePoint Online, which includes documents, lists, libraries, sites, and other data. This process is known as content crawling. The crawled content is then indexed, meaning it is analyzed, categorized, and stored in a structured format to facilitate efficient and quick searching.
- Query Processing: When a user initiates a search query, SharePoint Online processes the query to understand its context and intent. It analyzes the keywords, phrases, and other search parameters to determine the most relevant results.
- Ranking and Relevancy: SharePoint Online’s search algorithm ranks the indexed content based on several factors, such as relevance, recency, popularity, and user behavior. Content that matches the search query and is considered more relevant will be displayed higher in the search results.
- Search Results Presentation: Once the ranking is determined, SharePoint Online presents the search results in a user-friendly manner. The results are typically displayed in a list format, with titles, snippets, and metadata to provide a brief preview of each item.
- Filters and Facets: SharePoint Online Search also offers filters and facets to help users refine their search results. Users can filter results based on metadata like document type, author, modified date, or any custom metadata associated with the content.
- Search Scopes: SharePoint Online allows users to define specific search scopes. These scopes can be customized to limit searches to specific sites, document libraries, or other predefined areas. It helps users narrow down their search to relevant sections of the SharePoint Online environment.
- Customization and Configuration: SharePoint Online administrators have the ability to customize and configure the search experience. They can modify the search schema, manage crawled properties, define custom display templates, and set search settings to align with the organization’s requirements.
- Search Relevance Tuning: Organizations can use the search analytics and reporting in SharePoint Online to gain insights into how users interact with search results. Based on this information, administrators can fine-tune the search relevance to improve the overall search experience.
- Query Suggestions: SharePoint Online provides query suggestions, helping users refine their queries by suggesting related terms or phrases based on their input. This feature assists in guiding users to more accurate search results.
- Search Alerts: Users can set up search alerts to receive notifications when new content matching their search criteria is added or modified. This ensures that users stay updated with relevant information without actively performing searches.
SharePoint Online Search employs a systematic approach involving content crawling, indexing, query processing, ranking, and presenting results to provide an efficient and personalized search experience for users within the SharePoint Online environment.
Summary: Hide disable or inactive users from SharePoint online Search
Thus, in this technique, we have learned about how to hide disabled or inactive users from SharePoint online search in office 365.
Reference URL: SharePoint online search
- https://techcommunity.microsoft.com/t5/SharePoint-Support-Blog/Exclude-Users-From-Delve-and-SharePoint-Online-People-Search/ba-p/170731
- https://blogs.technet.microsoft.com/beyondsharepoint/2016/11/11/restrict-disabled-users-in-search-results/
- http://thomasdaly.net/2016/01/16/hiding-people-from-people-search/
- https://community.spiceworks.com/topic/2034603-hide-exchange-users-in-sharepoint-online-and-delve
See Also: SharePoint Online PowerShell
You may also like the below SharePoint Online tutorials:
- Office 365: Getting started with SharePoint PnP PowerShell – installation
- In 2 steps convert a classic SharePoint page to modern using PnP
- Office 365: Retrieve hub sites and associated sites using PnP Powershell
- Create a modern team site using PnP PowerShell in SharePoint
- In 4 steps access SharePoint online data using postman tool
- SharePoint admin center: Learn SharePoint online administration in an hour – step by step
- SharePoint REST API: GET vs POST vs PUT vs DELETE vs PATCH
- Office 365: Understanding the hub site in SharePoint online
- PowerApps hide show fields
- Conditionally show or hide columns in a SharePoint list
- SharePoint Online conditional row formatting based on a LOOKUP column value using JSON
- Power Automate[Detailed]: set item level permissions in SharePoint online step by step with HTTP request
- Office 365: Create content type in SharePoint Online using PnP PowerShell
- Office 365: How to create document library in SharePoint Online using PowerShell?
- HTML Table in Power Automate: Learn HTML table formatting using Microsoft Power Automate step by step
- Column header formatting in SharePoint list Quick Edit or Datasheet View
- SharePoint Hyperlink in Text Field: Convert a single line of text column to hyperlink using SharePoint column formatting
- Conditionally show or hide columns in a SharePoint list
- SharePoint Online – O365 – How to create a Tile view in modern SharePoint online lists and configure it.