Partager via


SP 2013 Search Box WebPart configuration using PowerShell

 

image

 
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
$spsite = Get-SPSite "https://2013-sp/"
$web = $spsite.RootWeb
$pageURL = "SitePages/Home.aspx"
$wpm = $web.GetLimitedWebPartManager($pageURL, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)
$searchWP = $wpm.WebParts | where-object { $_.WebBrowsableObject.GetType().Name -eq "SearchBoxScriptWebPart" }
if($searchWP -ne $null)
{
    $searchWP.TryInplaceQuery = 0
    $searchWP.ResultsPageAddress = "CustomSearchResultsPage.aspx"
    $wpm.SaveChanges($searchWP)
}