53,979 total views, 2 views today
Sometimes we may need to hide the disabled or inactive users from the SharePoint online search, then how to handle this? In this article, I will explain how to implement this.
Description:
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 disable/inactive users from the below SharePoint online search page, what is the approach to implement this?
1. https://sp.sharepoint.com/search/Pages/peopleresults.aspx
2. https://sp.sharepoint.com/sites/sales/_layouts/15/search.aspx
Resolution:
Step 1:
Get all disable 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:
Best way to update in bulk if we have more disabled users are as below:
- Export to CSV all disable 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 in the SharePoint search query page:
- Go to enterprise search people results page: https:///search/Pages/peopleresults.aspx Example: https://globalsharepoint.sharepoint.com/search/Pages/peopleresults.aspx
- Edit Search Results page
- Edit 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 must without this attribute changes 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. ”
Summary:
Thus, in this technique, we have learned about how to hide disable or inactive users from SharePoint online search in office 365.
Reference URL:
- 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:
- 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
