Forum Discussion
How to add managed properties to a SharePoint sites ?
You can already search for sites based on Title, WebUrl, etc. I'm assuming you want to add some custom metadata to tag your sites with and filter on that.
One option would be to utilize the Site property bag where you can add custom properties directly to the site - but not possible via the UI - would need to use PowerShell, Power Automate, SharePoint REST API, etc. and you would need to be a Site Collection Administrator to add the property to the site. Once the property has been added, it will be crawled, and you will be able to add it to a Managed Property, including a Refinable String if you need it to be refinable.
Here’s a straightforward way to add a custom site‐level property (in the property bag) via PowerShell, using the SharePoint PnP module. Once this is crawled, SharePoint will create a crawled property (like ows_q_TEXT_MyCustomSiteProperty) that you can then map to a managed property in your Search Schema.
# 1. Install PnP.PowerShell if you haven't already
# Install-Module PnP.PowerShell
# 2. Connect to your site
$siteUrl = "https://contoso.sharepoint.com/sites/YourSite"
Connect-PnPOnline -Url $siteUrl -Interactive
# 3. Add/update the property
# This writes to the root web’s property bag
$key = "MyCustomSiteProperty"
$value = "SomeValue"
Set-PnPPropertyBagValue -Key $key -Value $value
# 4. (Optional) Verify it’s there
Get-PnPPropertyBag | Where-Object { $_.Key -eq $key } | Format-Table Key, ValueWhat happens next:
- Wait for Search to crawl your site (or manually trigger an incremental crawl if on-prem).
- In the Search Administration (or via PnP/REST), find the new crawled property (usually named ows_q_TEXT_MyCustomSiteProperty).
- Create a new Managed Property and map that crawled property to it, so you can query/filter on it.