powershell 在SharePoint 2013中创建新的搜索服务应用程序。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell 在SharePoint 2013中创建新的搜索服务应用程序。相关的知识,希望对你有一定的参考价值。

# ----------------------------------------------
# Author: Romain Blanchard / Internet
# Date: 11.04.2014
# Description: Create new search service application in SharePoint 2013.
# ----------------------------------------------

# -- Initialize -- #
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

# -- Settings -- #
$IndexLocation = "C:\Data\Search15Index" #Location must be empty, will be deleted during the process! 
$SearchAppPoolName = "Search App Pool" 
$SearchAppPoolAccountName = "DSIN\SPFarm" 
$SearchServerName = (Get-ChildItem env:computername).value 
$SearchServiceName = "Search15" 
$SearchServiceProxyName = "Search15 Proxy" 
$DatabaseName = "Search15_ADminDB"

# -- Script -- #
Write-Host -ForegroundColor Yellow "Checking if Search Application Pool exists" 
$SPAppPool = Get-SPServiceApplicationPool -Identity $SearchAppPoolName -ErrorAction SilentlyContinue

if (!$SPAppPool) 
{ 
    Write-Host -ForegroundColor Green "Creating Search Application Pool" 
    $spAppPool = New-SPServiceApplicationPool -Name $SearchAppPoolName -Account $SearchAppPoolAccountName -Verbose 
}

# Start Services search service instance 
Write-host "Start Search Service instances...." 
Start-SPEnterpriseSearchServiceInstance $SearchServerName -ErrorAction SilentlyContinue 
Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $SearchServerName -ErrorAction SilentlyContinue

Write-Host -ForegroundColor Yellow "Checking if Search Service Application exists" 
$ServiceApplication = Get-SPEnterpriseSearchServiceApplication -Identity $SearchServiceName -ErrorAction SilentlyContinue

if (!$ServiceApplication) 
{ 
    Write-Host -ForegroundColor Green "Creating Search Service Application" 
    $ServiceApplication = New-SPEnterpriseSearchServiceApplication -Partitioned -Name $SearchServiceName -ApplicationPool $spAppPool.Name -DatabaseName $DatabaseName 
}

Write-Host -ForegroundColor Yellow "Checking if Search Service Application Proxy exists" 
$Proxy = Get-SPEnterpriseSearchServiceApplicationProxy -Identity $SearchServiceProxyName -ErrorAction SilentlyContinue

if (!$Proxy) 
{ 
    Write-Host -ForegroundColor Green "Creating Search Service Application Proxy" 
    New-SPEnterpriseSearchServiceApplicationProxy -Partitioned -Name $SearchServiceProxyName -SearchApplication $ServiceApplication 
}


$ServiceApplication.ActiveTopology 
Write-Host $ServiceApplication.ActiveTopology

# Clone the default Topology (which is empty) and create a new one and then activate it 
Write-Host "Configuring Search Component Topology...." 
$clone = $ServiceApplication.ActiveTopology.Clone() 
$SSI = Get-SPEnterpriseSearchServiceInstance -local 
New-SPEnterpriseSearchAdminComponent –SearchTopology $clone -SearchServiceInstance $SSI 
New-SPEnterpriseSearchContentProcessingComponent –SearchTopology $clone -SearchServiceInstance $SSI 
New-SPEnterpriseSearchAnalyticsProcessingComponent –SearchTopology $clone -SearchServiceInstance $SSI 
New-SPEnterpriseSearchCrawlComponent –SearchTopology $clone -SearchServiceInstance $SSI

Remove-Item -Recurse -Force -LiteralPath $IndexLocation -ErrorAction SilentlyContinue 
mkdir -Path $IndexLocation -Force

New-SPEnterpriseSearchIndexComponent –SearchTopology $clone -SearchServiceInstance $SSI -RootDirectory $IndexLocation 
New-SPEnterpriseSearchQueryProcessingComponent –SearchTopology $clone -SearchServiceInstance $SSI 
$clone.Activate()

Write-host "Your search service application $SearchServiceName is now ready"

以上是关于powershell 在SharePoint 2013中创建新的搜索服务应用程序。的主要内容,如果未能解决你的问题,请参考以下文章

powershell Powershell在SharePoint中查找特定字段类型的出现次数

PowerShell - 读取 SharePoint 文件属性(修改日期等)

使用PowerShell读取SharePoint里列表的内容

SharePoint PowerShell 启动工作流

powershell SharePoint网站权限。正在进行的PowerShell项目,以分解sharepoint网站集和所有部分的所有权限

powershell Powershell用于将Powershell与SharePoint 2007一起使用