Configurando Search SharePoint 2013: Usando PowerShell

Como falei no post anterior que iria postar o meu script para configurar o Search do SharePoint, o script esta bem explicado da ua olhadinha, qualquer dúvida estou a disposição!

Abra o PowerShell ISE no seu servidor de aplicação, copie e cole os comando e tenta entender antes de rodar 🙂

Convém salientar se for rodar um servidor Stand-Alone, algumas coisas no script devem ser mudadas, não precisamos passar o servidor de Banco, etc…

Vamos la então segue o script:

Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue # Add-PsSnapin SharePoint 🙂

#Settings
$IndexLocation = "C:\Search_GSD" #Location must be empty, will be deleted during the process!
$SearchAppPoolName = "Search App Pool" # Criando Application Pool para esse serviço ou vc pode usar um existente.
$SearchAppPoolAccountName = "BlogGSD\GSD_Owner" #Usuário com privilegios pra rodar o serviço.
$SearchServiceName = "BlogGSD Search Service Application" # Nome do serviço.
$SearchServiceProxyName = "BlogGSD Search Service Application Proxy" # Nome do serviço proxy.

$DatabaseServer = "GSDBE01" #Servidor de Banco de Dados
$DatabaseName = "SharePoint_Search" #Banco de dados que será criado.

Write-Host -ForegroundColor Yellow "Verificando se o usuário Search Application Pool existe..."
$spAppPool = Get-SPServiceApplicationPool -Identity $SearchAppPoolName -ErrorAction SilentlyContinue

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

Write-Host -ForegroundColor Yellow "Verificando se Search Service Application existe..."
$ServiceApplication = Get-SPEnterpriseSearchServiceApplication -Identity $SearchServiceName -ErrorAction SilentlyContinue
if (!$ServiceApplication)
{
 Write-Host -ForegroundColor Green "Criando Search Service Application..."
 $ServiceApplication = New-SPEnterpriseSearchServiceApplication -Name $SearchServiceName -ApplicationPool $spAppPool.Name -DatabaseServer $DatabaseServer -DatabaseName $DatabaseName
}

Write-Host -ForegroundColor Yellow "Verificando Search Service Application Proxy existe..."
$Proxy = Get-SPEnterpriseSearchServiceApplicationProxy -Identity $SearchServiceProxyName -ErrorAction SilentlyContinue
if (!$Proxy)
{
 Write-Host -ForegroundColor Green "Criando Search Service Application Proxy..."
 New-SPEnterpriseSearchServiceApplicationProxy -Name $SearchServiceProxyName -SearchApplication $SearchServiceName
}

$searchInstance = "GSDBE01" # Denifindo em que server irá rodar o Search Index Component
$InitialSearchTopology = $ServiceApplication | Get-SPEnterpriseSearchTopology -Active 
$SearchTopology = $ServiceApplication | New-SPEnterpriseSearchTopology

New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchTopology $SearchTopology -SearchServiceInstance $searchInstance
New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $SearchTopology -SearchServiceInstance $searchInstance
New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $SearchTopology -SearchServiceInstance $searchInstance
New-SPEnterpriseSearchCrawlComponent -SearchTopology $SearchTopology -SearchServiceInstance $searchInstance 
New-SPEnterpriseSearchAdminComponent -SearchTopology $SearchTopology -SearchServiceInstance $searchInstance

set-SPEnterpriseSearchAdministrationComponent -SearchApplication $ServiceApplication -SearchServiceInstance $searchInstance

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

New-SPEnterpriseSearchIndexComponent -SearchTopology $SearchTopology -SearchServiceInstance $searchInstance -RootDirectory $IndexLocation

Write-Host -ForegroundColor Green "Ativando a nova topologia..."
$SearchTopology.Activate()

Write-Host -ForegroundColor Yellow "Pode ignorar o erro a seguir :p !"
$InitialSearchTopology.Synchronize()

Write-Host -ForegroundColor Yellow "Deletando a topologia antiga..."
Remove-SPEnterpriseSearchTopology -Identity $InitialSearchTopology -Confirm:$false
Write-Host -ForegroundColor Green "Topologia velha deletada!"
Write-Host -ForegroundColor Green "Vamos rodar full crawl!!!!"

Tendo rodado o script, vamos ver o resultado, olhe as imagem seguintes para ver como ficou a configuração após a execução dos comandos.

fonte: https://social.technet.microsoft.com/wiki/contents/articles/32166.sharepoint-2013-configure-search-using-powershell-part-1-of-2.aspx

About Gustavo Delfino

Analista / Desenvolvedor de Sistemas com especialização em aplicações Web e SharePoint. Trabalho com .NET e SharePoint desde 2008. Também com Dynamics CRM desde de a versão 4.0. Certificações : MCTS, MCSD, MCSA e MCDS.
This entry was posted in PowerShell, Search SharePoint 2013, SharePoint 2013. Bookmark the permalink.

One Response to Configurando Search SharePoint 2013: Usando PowerShell

  1. Pingback: New-SPEnterpriseSearchServiceApplication : Value cannot be null. Parameter name: indexLocation | GSDelfino.NET

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s