Question

I want to search for content in a specific subsite in sharepoint online. How can I set scope of search to subsite in KQL using powershell csom?

I tried the following query:

$queryText="createdby:$OldAuthor contentclass:STS_ListItem_850  OR (IsDocument:1 FileType:doc* FileType:pdf* FileType:xls* FileType:ppt*) -ContentTypeId:0x0120* -path:{$siteUrl} "

But path parameter did not work and I got results from entire tenant. How can I restrict it to specific subsite?

Was it helpful?

Solution

Instead of using -path:{$siteUrl} try site:$($siteUrl), e.g.

$siteUrl = "https://contoso.sharepoint.com/subsite"

$QueryText = " ... site:$($siteUrl)"

OTHER TIPS

The character '-'(-path:) means Exclusion, I think you should remove it for your query.

Check here for Official document.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top