Sharepoint PowerShell query search service
In Powershell
param([string]$siteCollectionUrl="http://mySiteUrl" ,
$keyword="ContentTypeId:0x010100020D149374FFC4DF792F30EFC030C9D01* ",
$rowLimit=500,
$SelectProperties="Title,SPWebUrl,Path"
)
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$site = Get-SPSite $siteCollectionUrl
$keywordQuery = New-Object Microsoft.Office.Server.Search.Query.KeywordQuery($site);
#set request
$keywordQuery.QueryText = $keyword
#set managed properties to retreive
foreach($mnp in $SelectProperties.Split(","))
{
$keywordQuery.SelectProperties.Add($mnp.Trim());
}
$keywordQuery.RowLimit = $rowLimit
$searchExec = New-Object Microsoft.Office.Server.Search.Query.SearchExecutor
$searchResults = $searchExec.ExecuteQuery($keywordQuery)
#display results
$table = $searchResults.Table
$table | Select Title, SPWebUrl, Path
$site.Dispose()