0

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 ?

1
  • 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!! Commented Jan 27, 2012 at 9:16

1 Answer 1

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.