Create Indexed(Queryable via Search) Web PropertyBag using PnP and PowerShell

PropertyBag set against SharePoint web object can be indexed which means a corresponding crawled property is created by Search. If search managed properties are created against the crawled property (property bag values), custom search display templates can be created to provide a site directory solution.

The post by Phil Harding Set a PropertyBag Property as Indexed (Queryable via Search) using CSOM + Powershell   describes how to create an indexed property on premises using the collection “IndexedPropertyKeys”.

$web.IndexedPropertyKeys.Add("MyPropertyName")

However with CSOM, the collection “IndexedPropertyKeys” is not present. Indexed property can be added to another property instead “vti_indexedpropertykeys”.  Phil provided the following code how to add an indexed property.

Fortunately with SharePoint PnP, the indexed property can be added using one line of code.

Set-SPOPropertyBagValue -Key "EDRMS_Usage" -Value "Collaboration" -Indexed

 

Advertisements