Created
March 30, 2014 23:39
-
-
Save ishajain/9881879 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rite-Host "setting up the site collection level result souce for the site" -ForegroundColor yellow | |
| $resultSourceName="MyResultSource" | |
| $resultSourceDescription ="site collection result source" | |
| $query="{searchTerms?} Path:{SiteCollection.Url}" | |
| $ssa = Get-SPEnterpriseSearchServiceApplication "Search Service Application" | |
| $fedman = New-Object Microsoft.Office.Server.Search.Administration.Query.FederationManager($ssa) | |
| $searchOwner = Get-SPEnterpriseSearchOwner -SPWeb $web -Level SPSite | |
| $resultSource = $fedman.GetSourceByName($resultSourceName, $searchOwner) | |
| #Check To See if it exists | |
| if(!$resultSource){ | |
| $resultSource = $fedman.CreateSource($searchOwner) | |
| } | |
| $resultSource.Name =$resultSourceName | |
| $resultSource.ProviderId = $fedman.ListProviders()['Local SharePoint Provider'].Id | |
| $resultSource.Description = $resultSourceDescription | |
| $resultSource.CreateQueryTransform($query) | |
| $resultSource.Commit() | |
| Write-Host "Settings the Site Collection scope for the search results in the Search Results webpart" -ForegroundColor yellow |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment