Wednesday, November 9, 2011

Real World SharePoint : Creating Sharepoint 2010 Enterprise Search Center Sub Site using Powershell Part 1

This article will assist you through some of the potential pitfalls associated with creating a SharePoint 2010 Enterprise Search Center Sub Site. This task seems fairly trivial but you will run into problem along the way.

Context:

Company's Intranet Site Consists of a number of top level Departmental Site Collections. All departmental site collections reside within a single web application. A custom departmental site collection was created and deployed into the farm as a feature. The custom template is based on a 'Blank Site Template'

Version Of SharePoint Installed: SharePoint 2010 Standard

Requirement:
Create an Enterprise Search Center Site Sub Site that will exist underneath the Home Site Collection. Route 'All Sites' Search Results to the new Search Center Site

Usage Pattern:
When users land on the Home site or on the departmental site they will have the option to search the current site or to search 'All Sites'. When an 'All Sites' search is executed the results need to be shown within the Enterprise Search Center




Now that we understand the what and the why aspect of the solution we need to come up with the how. Since our Site Collections were created using Custom Site Definitions we will run into problems when we try to create a new Enterprise Search Center either using powershell or using the SharePoint Site Administration Web Interface.

Problem : Where is the Enterprise Search Center Template?

I went in and tried to manually create the search center but the Enterprise Search Center Site Template was not available? I also ran my powershell script to enumerate site level web templates and the Enterprise Search Center Site Template was not listed.

Cause:

Custom Site Definition did not include the Enterprise Search Center Template (remember that it was derived from a Blank Site Template) so it is not available within the Site Collection.

Workaround:

We can use powershell to get the Enterprise Search Center Template from the Farm.I created a simple powershell script that when run will enumerate the farm level templates. Once I got the name of the ESC template I was then able to retrieve it by name.


Step 1 :  Enumerate Farm Level Site Templates 


  Get-SPWebTemplate



























The above image outputs the available farm level  site templates. We  now have enough information to get the Search Center Site Template 'by name' 




Step 2:  Get Enterprise Search Center Template From Farm by Name:




























Step 3: Full Script:






















Unfortunately when we  run the script we get  an error :(.  Be sure to checkout part 2 of this series FTW!