1

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?

2 Answers 2

0

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

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

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

1

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

Check here for Official document.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.