Created
March 30, 2014 23:42
-
-
Save ishajain/9881921 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
| $resultSourceID=$resultSource.ID | |
| $resultSourceLevel="SPSite" | |
| $webURL =$web.Url + "/searchcentre" | |
| $web=Get-SPWeb $webURL | |
| $pageUrl="$webURL/Pages/results.aspx?k=test" | |
| $page=$web.lists["Pages"].Items | ? {$_.Name -eq "results.aspx"} | |
| $page.File.CheckOut(); | |
| $webpartmanager=$web.GetLimitedWebPartManager($pageUrl, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared) | |
| $webpart = $webpartmanager.WebParts | ? { $_.Title -eq 'Search Results' } | |
| $dataProvider = ConvertFrom-Json $webpart.DataProviderJSON | |
| $dataProvider.SourceID=$resultSourceID | |
| $dataProvider.SourceLevel=$resultSourceLevel | |
| $dataProvider.SourceName=$resultSourceName | |
| $webpart.DataProviderJSON = ConvertTo-Json $dataProvider -Compress | |
| $webpartmanager.SaveChanges($webpart) | |
| $page.File.CheckIn("Changed the Result Source") | |
| $page.File.Publish("Changed the Result Source") | |
| Write-Host "Site Collection scope for the search results in the Search Results webpart is set to 'MyResultSource' successfully" -ForegroundColor green |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment