
Creazione Search Service Application in SharePoint 2016
Script PowerShell per la creazione di una Search Service Application in SharePoint 2016
PowerShell
# nome dei server della farm utilizzare per il search
$hosts = @("<nome server 1>", "<nome server 2>", "<ecc...>")
# nome del server di database o alias SQL
$dbServer = "SharePointDB"
# nome del database di search
$searchDBName = "SP2016_Search"
# account usato dal search es. dominio\SPSearchService
$searchUser = "<dominio\account>"
$searchPwd = ConvertTo-SecureString -String '<account password>' -AsPlainText -Force
$serviceAppName = "Search Service Application"
$svcAppPoolName = "SharePoint Web Services System"
#Wait for service OnLine on Every Host
$hosts | % {
Write-Output "Host $($_.Server.Address) start"
$ss1 = Get-SPEnterpriseSearchServiceInstance -Identity $_
if ($ss1.Status -ne "Online") {
Start-SPEnterpriseSearchServiceInstance -Identity $_
Write-Output "wait"
$ss1 = Get-SPEnterpriseSearchServiceInstance -Identity $_
while ($ss1.Status -ne "Online")
{
Write-Output "."
Start-Sleep 5
$ss1 = Get-SPEnterpriseSearchServiceInstance -Identity $_
}
} else {
Write-Output "already online"
}
}
Write-Output "Current status"
Get-SPEnterpriseSearchServiceInstance
Write-Output "Get-SPEnterpriseSearchServiceApplication $serviceAppName"
$searchApp = Get-SPEnterpriseSearchServiceApplication $serviceAppName -ErrorAction SilentlyContinue
if ($searchApp -eq $null)
{
Write-Output "Create $serviceAppName"
$saAppPool = Get-SPServiceApplicationPool | where { $_.Name -eq $svcAppPoolName }
$searchApp = New-SPEnterpriseSearchServiceApplication -Name $serviceAppName -ApplicationPool $saAppPool -DatabaseServer $dbServer -DatabaseName $searchDBName
}
$searchSvcAccount = Get-SPManagedAccount $searchUser -ErrorAction SilentlyContinue
if ($searchSvcAccount -eq $null)
{
Write-Output "Create managed account -SPEnterpriseSearchService"
$searchSvcAccount = New-SPManagedAccount $searchUser
}
Write-Output "Set-SPEnterpriseSearchService"
$svc = Get-SPEnterpriseSearchService
Set-SPEnterpriseSearchService `
-Identity $svc `
-ServiceAccount $searchSvcAccount.UserName `
-ServicePassword $searchPwd `
-ContactEmail " " `
-ConnectionTimeout "60" `
-AcknowledgementTimeout "60" `
-ProxyType "Default" `
-PerformanceLevel "PartlyReduced"
#Create Proyx for Service Application
Write-Output "Create $serviceAppName Proxy"
$searchProxy = New-SPEnterpriseSearchServiceApplicationProxy -Name "$serviceAppName Proxy" -SearchApplication $searchApp