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?

有帮助吗?

解决方案

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

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

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

其他提示

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

Check here for Official document.

许可以下: CC-BY-SA归因
scroll top