2011-05-31 73 views
1

使用powershell如何創建使用BDC的內容追蹤?使用PowerShell創建使用BDC的SharePoint 2010搜索內容源

Technet上關於New-SPEnterpriseSearchCrawlContentSource的文檔不太清楚如何做到這一點。

到目前爲止,這對我來說似乎最合理,但它不起作用。

$searchapp = Get-SPEnterpriseSearchServiceApplication "MySearchApplication" 
New-SPEnterpriseSearchCrawlContentSource -name "My BDC Content Source" -searchapplication $searchApp -Type Business -LOBSystemSet "NameOfMyBdc" 

它創建了Business Data Connectivity類型的內容源,但未檢查指定的BDC。

回答

1

浪費了很多時間在這個,但最終得到它的工作。這是對我有用的,如果你有更好的解決方案,請分享。

$searchapp = Get-SPEnterpriseSearchServiceApplication "My Search Service Application Name" 
$lobSystems = @("LOBSystemName1","LOBSystemInstanceName1") 
$proxyGroup = Get-SPServiceApplicationProxyGroup -default 
New-SPEnterpriseSearchCrawlContentSource -name "My Content Source Name" -searchapplication $searchApp -Type Business -LOBSystemSet $lobSystems -BDCApplicationProxyGroup $proxyGroup 

您也可以使用這樣的API來做到這一點。我不知道ConstructStartAddress方法的Guid PartitionId參數是什麼,但它似乎不適用於任何其他Guid。

 string strURL = "http://mySiteUrl"; 
     SearchContext searchContext; 
     using (SPSite searchSite = new SPSite(strURL)) 
     { 
      searchContext = SearchContext.GetContext(searchSite); 
     } 
     Content sspContent = new Content(searchContext); 
     ContentSourceCollection sspContentSources = sspContent.ContentSources; 
     BusinessDataContentSource bdcs = (BusinessDataContentSource)sspContentSources.Create(typeof(BusinessDataContentSource), "MyBdcContentSource"); 
     bdcs.StartAddresses.Add(BusinessDataContentSource.ConstructStartAddress("Default", new Guid("00000000-0000-0000-0000-000000000000"), "LOBSystemName", "LOBSystemInstanceName"));