SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am new to Shell Script. I would like to write a script to generate new content source for search. I wrote the following code to create a content source.

$searchapp = Get-SPEnterpriseSearchServiceApplication "Search Service Application"
New-SPEnterpriseSearchCrawlContentSource -SearchApplication $searchapp -Type SharePoint -name "SomeName" -StartAddresses "http://yoursite/subsite"

When I run the above script I am getting error like as follows

New-SPEnterpriseSearchCrawlContentSource : Only web applications can be specified when a Microsoft SharePoint Server content source is set to crawl web applications.

I would like to add a subsite in my startaddress.. how can i do that ? Any ideas ?

share|improve this question
I have a requirement to create a content source of type "web" with the option "Only crawl within the server of each start address" via powershell. I am trying the below command : New-SPEnterpriseSearchCrawlContentSource -SearchApplication <ssa_name> -Type Web -name Sample -StartAddresses <<Start_url>> The problem is it is always selecting the third option "Custom - specify page depth and server hops". Is there any specific parameter or anything that I am missing. Thanks in Advance!! – Arun Jan 27 '12 at 9:16

The reason for this error is that the default crawl behaviour is to crawl everything under the hostname for the start address, and this only makes sense if the start address is a hostname. To crawl a specific site you need to add the parameter -SharePointCrawlBehavior CrawlSites, and it should allow you to specify a more specific start address.

There are equivalent Crawl Settings options when you set up a content source throught the UI.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.