Hi guys in this post I'm going to show how can we configure people search using PowerShell. There are some prerequisites for people search.
People search prerequisites:
- Search Service Application should be running in the SharePoint farm.
- SharePoint farm also should have a Search Center. (Enterprise Search Center)
- Managed Metadata Application should be running in the SharePoint farm.
- User Profile Service should be configured and running in the farm.
- MySite Should be configured.
So check the above given prerequisites are working in your SharePoint farm.
These are the steps to configure people search:
- Check whether your user account has administrator privileges on both Search Service Application and User Profile Service Application.
- Create a new crawl rule
#Creating a crawl rule for MySite Web Application
$Path = "sps3://<host name>"
$UserName = Read-Host "Enter Username"
$Password = Read-Host "Enter Password" -AsSecureString
$SearchApp = Get-SPEnterpriseSearchServiceApplication
$Rule = New-SPEnterpriseSearchCrawlRule -SearchApplication $SearchApp -Path $Path -Type InclusionRule -AuthenticationType BasicAccountRuleAccess -AccountName $UserName -AccountPassword $Password
$Rule.Update()
Write-Host -f Green "New Rule created"
Before you run this script specify the Url of the Web Application where MySite is deployed (Url format is: sps3://<host name>) for $Path variable. It'll prompt for user authentication give the correct user credentials which has the administrator privileges.
- Remove the Url of the Web Application where MySite is deployed from the default Content Source (Local SharePoint Sites)
#Removing the MySite Url from the default Content Source
$search = Get-SPEnterpriseSearchServiceApplication "Search Service Application"
$contentSource = Get-SPEnterpriseSearchCrawlContentSource -SearchApplication $search -Identity "Local SharePoint Sites"
$addresses = $contentSource.StartAddresses
$addresses.Remove($Path)
$contentSource.Update()
Write-Host -f Green "Web Application Url of MySite successfully removed from default content source"
Before you run this script specify the name of your Search Service Application for $search variable.
- Now create a new Content Source with Url that you removed from the default Content Source.
#Creating a new content source for MySite
New-SPEnterpriseSearchCrawlContentSource -SearchApplication $search -Type SharePoint -name "MySite" -StartAddresses $Path
Write-Host -f Green "New content source is successfully created for MySite"
After you run this script new Content Source will be created with the name "MySite". Go to manage content sources in Search Service Application, click on the newly created Content Source and click "Start Full Crawl".
Now good to go people search is successfully configured.
Feel free to give your feed backs.
Cheers.
Luckshan Roy.