Un esempio di come interrogare, in PowerShell il motore di ricerca full text di SharePoint:

PowerShell

$url = "http://sharepoint2010.sgart.local/sites/test/"
$userLogin = "sgart\searchtest"
$keyword = "casa"

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") 
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server") 
[void][reflection.assembly]::Loadwithpartialname("Microsoft.office.server.search") 

$site = new-object Microsoft.SharePoint.SPSite($url)

$context = [Microsoft.Office.Server.ServerContext]::GetContext($siteUser)

$kwd = new-object Microsoft.Office.Server.Search.Query.KeywordQuery($context);
#setto la lingua italiana
$kwd.Culture = new-object System.Globalization.CultureInfo(1040);

#ResultType=DefinitionResults,HighConfidenceResults,None,RelevantResults,SpecialTermResults
$kwd.ResultTypes = [Microsoft.Office.Server.Search.Query.ResultType]::RelevantResults;
$kwd.StartRow = 0;
$kwd.RowLimit = 20;
$kwd.EnableStemming = $true;
$kwd.TrimDuplicates = $true;
$kwd.IgnoreAllNoiseQuery = $true;

#KeywordInclusion=AllKeywords,AnyKeyword;
$kwd.KeywordInclusion = [Microsoft.Office.Server.Search.Query.KeywordInclusion]::AnyKeyword;
$kwd.QueryText = $keyword;

#execute search
$results = $kwd.Execute();
$result = $results[[Microsoft.Office.Server.Search.Query.ResultType]::RelevantResults];

#result print (Title, Rank, Author, Size, Path
$result.Table | Select Title, Path | Format-List

$kwd.dispose()
$site.dispose()
Tags:
PowerShell200 Search8 SharePoint498 SharePoint 2007218 SharePoint 2010224
Potrebbe interessarti anche: