Deploying the Search Query modifier
Unlike the previous two extensions, the Search Query modifier can be added only at the site collection level. This makes sense because we do not want to affect the Search Query modification at the tenant level and override the search behavior of the tenant.
Just like earlier, we can use scripts to add this extension to a site collection.
PnP PowerShell
The PnP PowerShell cmdlet needed for adding a Search Query modifier to a site is Add-PnPCustomAction. In our case, the command would be as follows:
Add-PnPCustomAction -Title "PacktProductSearchQueryModifier" -Name "PacktProductSearchQueryModifier" -Location "ClientSideExtension.SearchQueryModifier" -ClientSideComponentId 37f614c8-2e8a-43f9-abb1-d924ea9fab26
Running this command will add the Search Query modifier to the site.
CLI for Microsoft 365
The command to run would be spo customaction add. In our case, the command would be similar to the following...