2015-11-04 81 views
0

我正在通过PowerShell脚本设置SharePoint 2013搜索中心。我可以将内容源,爬网规则等等,所有这似乎工作很好,但我不能创建一个“ResultSource”:'New-SPEnterpriseSearchResultSource'未被识别为cmdlet的名称

PS > New-SPEnterpriseSearchResultSource 
New-SPEnterpriseSearchResultSource : The term 'New-SPEnterpriseSearchResultSource' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. 
At line:1 char:1 
+ New-SPEnterpriseSearchResultSource 
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    + CategoryInfo   : ObjectNotFound: (New-SPEnterpriseSearchResultSource:String) [], CommandNotFoundException 
+ FullyQualifiedErrorId : CommandNotFoundException 

这是奇怪的。它看起来像名单New-SPEnterpriseSearchResultSource on Technet底部的那些cmdlet只是不存在:我有“SearchResultItemType(s)”的功能,但没有“SearchResultSrouce(s)”的功能。

PS > Get-Command -Module *Sharepoint* -name *SearchResult* 

CommandType  Name            ModuleName 
-----------  ----            ---------- 
Cmdlet   Get-SPEnterpriseSearchResultItemType    Microsoft.SharePoint.PowerShell 
Cmdlet   New-SPEnterpriseSearchResultItemType    Microsoft.SharePoint.PowerShell 
Cmdlet   Remove-SPEnterpriseSearchResultItemType   Microsoft.SharePoint.PowerShell 
Cmdlet   Set-SPEnterpriseSearchResultItemType    Microsoft.SharePoint.PowerShell 

有没有人曾经遇到过这个?

回答

0

您必须加载程序集搜索

[void] [Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server.Search") 

基本代码如下

$publishingSite = Get-SPSite "http://c4968397007:1000/" 
$sspApp = Get-SPEnterpriseSearchServiceApplication; 

# load Search assembly 

[void] [Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server.Search") 

# create manager instances 

$fedManager = New-Object Microsoft.Office.Server.Search.Administration.Query.FederationManager($sspApp) 
$searchOwner = New-Object Microsoft.Office.Server.Search.Administration.SearchObjectOwner([Microsoft.Office.Server.Search.Administration.SearchObjectLevel]::Ssa, $publishingSite.RootWeb) 

# define query 

$query = '{searchTerms?}' 
$queryProperties = New-Object Microsoft.Office.Server.Search.Query.Rules.QueryTransformProperties 
# define custom sorting 
$sortCollection = New-Object Microsoft.Office.Server.Search.Query.SortCollection 
$sortCollection.Add("Title", [Microsoft.Office.Server.Search.Query.SortDirection]::Ascending) 
$queryProperties["SortList"] = [Microsoft.Office.Server.Search.Query.SortCollection]$sortCollection 

# create result source 
$resultSource = $fedManager.CreateSource($searchOwner) 
$resultSource.Name = 'Result Source Through PowerShell' 
$resultSource.ProviderId = $fedManager.ListProviders()['Local SharePoint Provider'].Id 
$resultSource.CreateQueryTransform($queryProperties, $query) 

$resultSource.Commit() 

你可以看到更多的这种link

+0

你好 - 感谢您的答复,但它似乎没有有所作为。它加载得很好(版本v4.0.30319?),但仍然不能识别术语'New-SPEnterpriseSearchResultSource'。 –

相关问题