Welcome to MSDN Blogs Sign in | Join | Help

SharePoint Brew

Russmax [MSFT] weblog
SharePoint 2010 Configuring Search Service Application using PowerShell

Create Search Service Application using PowerShell

It might be necessary at some point to use PowerShell to provision search service applications.  For Example, setting up a search service application for hosted sites requires you to use PowerShell.  The following steps manually take you through this process and I highly recommend going through the steps to become more familiar with the command-lets.  ​

Creating Search Service Application using PowerShell

1. Create Application Pool

Creating a an application pool for your search service application and throwing the object into a variable called $ app:

      $app = new-spiiswebserviceapplicationpool –name contososearch-apppool –account domain\user

2. Create search service application

      $searchapp = new-spenterprisesearchserviceapplication -name ContosoSearchServiceApplication -applicationpool $app

Note: Add the -partitioned switch after -name if the search service application will be consumed in a hosted environment.

     3. Create search service application proxy

new-spetnerprisesearchserviceapplicationproxy -name Contososearchserviceapplicationproxy -searchserviceapplicationuri https://contoso:32844/topology/topology.svc?topologyid=c60d41c9-2966-47df-931a-f3ff6f9fbb46"&"appid=bde9d415-7f65-44c8-8fcf-928aa710430c

            Note: Add the -partitioned switch after -searchserviceapplicationuri if the search service application will be consumed in a hosted environment.

Important:  It's recommended to use double quotes around URL but that will fail because it processes the & as an operator.  You must put quotes around the & to pass it as a string.  It doesn't work when using both sets of quotes.  For Example, One set of double "" for wrapping URI and single " for wrapping the & symbol. 

Problem finding the searchserviceapplicationURI?

You can run the following commands to determine this:

A. $contoso = get-spenterprisesearchserviceapplication  ContosoSearchServiceApplication

    B. $contoso | get-member  

URI should be listed as a property

C. $contoso.URI

        Will display the absoluteURi which is what you will use in the –searchserviceapplicationURI parameter

Verify the search service application proxy is online.

If it's not online, you can change the status by punching in the following:

$changestatus = get-spenterprisesearchserviceapplicationproxy hostedsearchproxy

$changestatus | get-member

This will display all the methods and properties available.  One of those properties is status.  To change this property you could type something like this:

$changestatus.status = “online”

Finally, you must update the change by calling the update method.

$changestatus.update()

4. Provision Search Administration Component

Configure the administration component of the associated Searchserviceapplication.  You can do this with the following steps:

$searchapp = get-spenterprisesearchserviceapplication “name of service application”

$si = get-spenterprisesearchserviceinstance –local

set-enterprisesearchadministrationcomponent –searchapplication $searchapp  –    searchserviceinstance $si

 

5. Provision Crawl and Query Components

By default, a search application created in PowerShell has a crawl topology but is missing the following:

· crawl component           

· query component

You cannot add a crawl\query component to the default crawl\query topology because it's set as active and the property is read only.  The easiest way around this is creating a new crawl topology and new query topology.  After creating both, they will be set as inactive by default.  This allows for both crawl components to be added to crawl topology and query component to be added to newly created query topology. Finally, you can set this new crawl topology to active. 

 

Steps are the following:

a. Create object for corresponding search application

$searchapp = get-spenterprisesearchserviceapplication "name of service application"

b. Create Crawl Topology

Create object and input output of newly created crawl topology.

$ct = $searchapp | new-spenterprisesearchcrawltopology

What if you already created a new crawl topology but never dropped it in a variable.  That's okay, you can still drop it in a variable.  First, you must know the ID for the crawl topology which should still be marked as inactive.

$searchapp | get-spenterprisesearchcrawltopology

Let's say the ID in this case is 2e25dcbf-ee71-41e4-b843-3f17d1064386.

$ct = $crawltopology  = $searchapp | where-object {$_.id -eq "2e25dcbf-ee71-41e4-b843-3f17d1064386"}

c. Provision Crawl Component

Create a crawl component for new crawl topology.  $ct can be passed as the identified crawl topology.  We still need to know the crawl store ID because it's     required to create the new-spenterprisesearchcrawlcomponent. 

To find the Guid we can run the following:

$searchapp.crawlstores

                   Copy the GUID for ID.  For Example:

74278909-cb14-46ee-96e2-69ad77ffdfc0

Create a new crawl component.

                   new-spenterprisesearchcrawlcomponent -searchapplication $searchapp -crawltopology $ct -crawldatabase "74278909-cb14-46ee-96e2-69ad77ffdfc0"

Finally, set the new crawl topology as active.

$ct | set-spenterprisesearchcrawltopology -active

d. Create Query Topology

                        Create new Query topology into object $qt

                        $qt = $searchapp | new-spenterprisesearchquerytopology -partitions 1

                        $p1 = ($qt | get-spenterprisesearchindexpartition)

e. Provision query component

    Create a query component for new query topology

                        new-spenterprisesearchquerycomponent -indexpartition $p1 -querytopology $qt -searchserviceinstance $si

                        $p1 | set-spenterprisesearchindexpartition

                        Assign the property store to the index partition

                        $p1 | set-spenterprisesearchindexpartition -propertydatabase "GUID HERE"

                        Where is the propertydatabase GUID?

$searchapp.propertystores to copy the ID "GUID"

Finally, set the query topology as active

$qt | set-spenterprisesearchquerytopology –active

Posted: Tuesday, October 20, 2009 7:29 PM by Russmax

Comments

Pankaj Jain said:

I really appriciate if you will provide me the details of configuring search in 2010.I already configured search in 2007 but in 2010 there is no concept of SSP.That's the reason,i want to know how to configure search in 2010.

# November 19, 2009 8:46 AM

Jerry said:

this does not work in Beta 1.

Please update.

# November 26, 2009 11:40 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker