How can i exclude "Forms/DispForm.aspx?" from search results using the search api for SharePoint Online?
I tried the following querytext:
$querytext= path: *: // * /DispForm.aspx*
But it is not working and is throwing an error:"Search has encountered a problem that prevents results from being returned"
Please suggest a solution.
EDIT
I need to get Documents(docx,pdf,xslx,ppt..) and pages only from the whole tenant. But i am also getting Forms\DispForm.aspx?ID=1 (when i checked this url,this is a js file). So how can i exclude js files? Below is my script. Kindly help me.
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($webApp)
$Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userName,$securePassword)
$Context.Credentials = $Creds
$keywordQuery = New-Object Microsoft.SharePoint.Client.Search.Query.KeywordQuery($Context)
$queryText="createdby:xxxx contentclass:STS_ListItem_850 contentclass:STS_ListItem_DocumentLibrary -fileextension:html -ContentTypeId:0x0120*"
$keywordQuery.QueryText = $queryText
$keywordQuery.SelectProperties.Add("Created")
$keywordQuery.SelectProperties.Add("LastModifiedTime")
$keywordQuery.SelectProperties.Add("CreatedBy")
$keywordQuery.SelectProperties.Add("ModifiedBy")
$keywordQuery.SelectProperties.Add("ListItemID")
$keywordQuery.SelectProperties.Add("ListID")
$keywordQuery.SelectProperties.Add("SPWebUrl")
$searchExecutor = New-Object Microsoft.SharePoint.Client.Search.Query.SearchExecutor($Context)
$results = $searchExecutor.ExecuteQuery($keywordQuery)
$Context.ExecuteQuery()
Write-Host $results.Value[0].ResultRows.Count
$exportlocation = "CSV path to export"