kwizcom banner advertisement

Add New Content Source in SharePoint 2013 Search using PowerShell

Requirement: Create new search content source in SharePoint 2013.

PowerShell script to add new content source:
Here is the PowerShell script to create new content source in SharePoint 2013 search.
Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue

#Variables for new content source creation
$ContentSourceName= "Intranet Portal" #default "Local SharePoint sites"
$ContentSourceType="SharePoint"
$ContnetSourceURL="http://portal.crescent.com"

#Get the search service application
$SSA = Get-SPEnterpriseSearchServiceApplication #-Identity "Search Service Application Name"

#Check if the given content source Name exits already
$ContentSource = Get-SPEnterpriseSearchCrawlContentSource -SearchApplication $SSA | where {$_.Name -eq $ContentSourceName}
if ($ContentSource)
{
    write-host "Content Source Name already exist!" -f Red
    exit
}
 
#Create new content source
$ContentSource = New-SPEnterpriseSearchCrawlContentSource -SearchApplication $SSA -Type $ContentSourceType `
          -name $ContentSourceName -StartAddresses $ContnetSourceURL -MaxSiteEnumerationDepth 0

write-host "New Content Source has been created!" -f Green

#To delete a content source, use: 
#Remove-SPEnterpriseSearchCrawlContentSource -SearchApplication $SSA -Identity $ContentSourceNames
You must run full crawl for any new content source created. Here is how: How to Start SharePoint Search Crawl using PowerShell

New-SPEnterpriseSearchCrawlContentSource reference in technet.
Add New Content Source in SharePoint 2013 Search using PowerShell Add New Content Source in SharePoint 2013 Search using PowerShell Reviewed by Salaudeen Rajack on May 28, 2015 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.