Just wanted to share the following script of mine. Hope it helps.
[sourcecode language=”powershell”]
#Parameters
#-scope : The search scope that you defined in Central Admin
#-keyword: Keyword to search.
Param
(
[string]$scope = $null,
[string]$keyword = $null
)
if($keyword -eq "")
{
Write-Host "You must key in the Keyword"
exit
}
$proxy = Get-SPEnterpriseSearchServiceApplicationProxy
$query = New-Object Microsoft.Office.Server.Search.Query.KeywordQuery($proxy)
$query.QueryText = $keyword
if($scope -ne $null)
{
$query.HiddenConstraints = "scope:`"" +$scope + "`""
}
#Add any properties you would like to return here
$query.SelectProperties.Add("title") | Out-Null
$query.SelectProperties.Add("url") | Out-Null
$query.ResultTypes = [Microsoft.Office.Server.Search.Query.ResultType]::RelevantResults
$query.RowLimit = 100
$query.ResultsProvider = [Microsoft.Office.Server.Search.Query.SearchProvider]::FASTSearch
Write-Host "Executing keyword search…"
$results = $query.Execute()
$relevants = $results["RelevantResults"]
#Or you can use [Microsoft.Office.Server.Search.Query.ResultType]::RelevantResults instead
Write-Host "Total " $relevants.TotalRows " results"
Write-Host ""
$relevants.Table
[/sourcecode]
Do note that this script is trying to make FAST Search query. If you are using SharePoint Enterprise Search, please change the ResultsProvider to SharePointSearch
Note also this is not FQL, i tried using “$query.EnableFQL = $true” and the scope didn’t work.