如何使用 powershell 创建使用 BDC 的内容源?
Technet 上的 New-SPEnterpriseSearchCrawlContentSource 文档对于如何执行此操作不是很清楚。
到目前为止,这对我来说似乎是最合理的,但它不起作用。
$searchapp = Get-SPEnterpriseSearchServiceApplication "MySearchApplication"
New-SPEnterpriseSearchCrawlContentSource -name "My BDC Content Source" -searchapplication $searchApp -Type Business -LOBSystemSet "NameOfMyBdc"
它创建业务数据连接类型的内容源,但未选中指定的 BDC。
这对我有用。
$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"));