TIVOLO Systems GmbH
TSG_Article_SP-01

Das Erstellen einer Suchdienstanwendung in SharePoint 2013 lässt sich per PowerShell automatisieren. Anbei das Skript, welches wir zu diesem Zweck verwenden:

  • Schritt 1: Variablen deklarieren
    # Create a new Search Service Application in SharePoint 2013
    Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
    # Settings
    $IndexLocation = "C:\Data\Search15Index”
    $SearchAppPoolName = "Search App Pool"
    $SearchAppPoolAccountName = "domain\username"
    $SearchServerName = (Get-ChildItem env:computername).value
    $SearchServiceName = "NameDerNeuenSuchdienstanwendung"
    $SearchServiceProxyName = "Search15 Proxy"
    $DatabaseName = "Search15_ADminDB"
  • Schritt 2: Prüfen auf existierenden Application Pool
    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
    }
  • Schritt 3: Suchdienst Instanz starten
    # Start Services search service instance
    Write-host "Start Search Service instances...."
    Start-SPEnterpriseSearchServiceInstance $SearchServerName -ErrorAction SilentlyContinue
    Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $SearchServerName -ErrorAction SilentlyContinue
  • Schritt 4: Suchdienstanwendung erstellen
    #Create Search Service Appplication
    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
    }
  • Schritt 5: Proxy erstellen
    #Create Search Service Application Proxy
    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
    }
  • Schritt 6: Topologie Konfigurieren
    #Configure Search Component Topology
    $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"

http://blogs.technet.com/b/praveenh/archive/2013/02/07/create-a-new-search-service-application-in-sharepoint-2013-using-powershell.aspx

 

TSG_Article_SP-01

Zum Löschen einer korrupten Suchdienstanwendung oder auch einer normalen Suchdienstanwendung, kann man wie üblich die ZA verwenden.

Schneller geht es aber über die PowerShell. Dazu in zwei Schritten vorgehen:

  • Variable mit der Dienstanwendung füllen:
     $spapp = Get-SPServiceApplication -Name "Name der Dienstanwendung"
  • Aufrufen des Befehle zum Löschen der Dienstanwendung:
     Remove-SPServiceApplication $spapp -RemoveData