Skip to content

SPSearchServiceApp

dscbot edited this page Mar 17, 2023 · 20 revisions

SPSearchServiceApp

Parameters

Parameter Attribute DataType Description Allowed Values
Name Key String The name of the search service application
ProxyName Write String The proxy name, if not specified will be /Name of service app/ Proxy
ApplicationPool Required String The application pool that it should run in
SearchCenterUrl Write String The URL of the enterprise search center site collection
DatabaseName Write String The name of the database (noting that some search databases will use this as a prefix)
DatabaseServer Write String The server that host the databases for this service application
UseSQLAuthentication Write Boolean Should SQL Server authentication be used to connect to the database?
DatabaseCredentials Write PSCredential If using SQL authentication, the SQL credentials to use to connect to the instance
DefaultContentAccessAccount Write PSCredential The default content access account for this search service app
CloudIndex Write Boolean Should this search service application be a cloud based service app
AlertsEnabled Write Boolean Should alerts be enabled for this search service application
FixFarmAccountPermissions Write Boolean Should the permissions for the Farm account on the Search databases be corrected
Ensure Write String Present if the service app should exist, absent if it should not Present, Absent
ErrorDeleteCountAllowed Write UInt16 Specifies the number of consecutive crawls where Access Denied or File Not Found errors were encountered before the item is deleted from the index
ErrorDeleteIntervalAllowed Write UInt16 Specifies the number of hours since the first Access Denied or File Not Found errors were encountered in a crawl before the item is deleted from the index
ErrorCountAllowed Write UInt16 Specifies the number of consecutive crawls where other errors were encountered before the item is deleted from the index
ErrorIntervalAllowed Write UInt16 Specifies the number of hours since the first other errors were encountered in a crawl before the item is deleted from the index
DeleteUnvisitedMethod Write UInt16 Specifies what items get deleted: 0 - All unvisited items, 1 - (Default) All unvisited items that have the same host as the start address, 2 - None of the unvisited items. You can specify the following three values:
RecrawlErrorCount Write UInt16 Specifies the number of consecutive crawls in which errors were encountered while fetching changes from the SharePoint content database
RecrawlErrorInterval Write UInt16 Specifies the number of hours since the first error were encountered while fetching changes from the SharePoint content database

Description

Type: Distributed Requires CredSSP: No

This resource is responsible for provisioning the search service application. The current version lets you specify the database name and server, as well as the application pool. If the application pool is changed the DSC resource will set it back as per what is set in the resource. The database name parameter is used as the prefix for all search databases (so you will end up with one for the admin database which matches the name, and then "_analyticsreportingstore", "_crawlstore" and "_linkstore" databases as well).

The default value for the Ensure parameter is Present. When not specifying this parameter, the service application is provisioned.

For more information about the Deletion Policy settings, check the following article: https://docs.microsoft.com/en-us/previous-versions/office/sharepoint-server-2010/hh127009(v=office.14)?redirectedfrom=MSDN

NOTE: Don't forget to configure a Search topology using the SPSearchTopology resource!

NOTE2: The resource is also able to add the Farm account as db_owner to all Search databases, to prevent the issue described here: https://www.techmikael.com/2014/10/caution-if-you-have-used.html Use the FixFarmAccountPermissions parameter to implement this fix (default $true if not specified).

Examples

Example 1

This example creates a new search service app in the local farm

Configuration Example
{
    param
    (
        [Parameter(Mandatory = $true)]
        [PSCredential]
        $SetupAccount
    )

    Import-DscResource -ModuleName SharePointDsc

    node localhost
    {
        SPSearchServiceApp SearchServiceApp
        {
            Name                 = "Search Service Application"
            DatabaseName         = "SP_Search"
            ApplicationPool      = "SharePoint Service Applications"
            PsDscRunAsCredential = $SetupAccount
        }
    }
}

Example 2

This example removes a search service app in the local farm. The ApplicationPool parameter is still required but is not actually used, so its value does not matter.

Configuration Example
{
    param
    (
        [Parameter(Mandatory = $true)]
        [PSCredential]
        $SetupAccount
    )

    Import-DscResource -ModuleName SharePointDsc

    node localhost
    {
        SPSearchServiceApp SearchServiceApp
        {
            Name                 = "Search Service Application"
            Ensure               = "Absent"
            ApplicationPool      = "n/a"
            PsDscRunAsCredential = $SetupAccount
        }
    }
}

Example 3

This example creates a new search service app in the local farm

Configuration Example
{
    param
    (
        [Parameter(Mandatory = $true)]
        [PSCredential]
        $SetupAccount
    )

    Import-DscResource -ModuleName SharePointDsc

    node localhost
    {
        SPSearchServiceApp SearchServiceApp
        {
            Name                       = "Search Service Application"
            DatabaseName               = "SP_Search"
            ApplicationPool            = "SharePoint Service Applications"
            ProxyName                  = "Search Service Application Proxy"
            SearchCenterUrl            = "https://intranet.contoso.com/sites/search"
            AlertsEnabled              = $true
            ErrorDeleteCountAllowed    = 10
            ErrorDeleteIntervalAllowed = 240
            ErrorCountAllowed          = 15
            ErrorIntervalAllowed       = 360
            DeleteUnvisitedMethod      = 1
            RecrawlErrorCount          = 5
            RecrawlErrorInterval       = 120
            Ensure                     = "Present"
            PsDscRunAsCredential       = $SetupAccount
        }
    }
}
Clone this wiki locally