How to set Web Part properties using Powershell in SharePoint 2013/2016?

Hello SharePointers,

In this blog, we will how to set Web Part properties using Powershell in SharePoint 2013/2016

$WebURL=”http://myspsite”
$FilePath=”/Lists/employer/AllItems.aspx”;
$WebPartTitle=”Employer”;

$web = Get-SPWeb $WebURL
$page = $web.GetFile($FilePath)
$page.CheckOut()
$WebPartManager = $web.GetLimitedWebPartManager($Page.ServerRelativeUrl,[System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)

#Get the Web part
$Webpart = $WebPartManager.WebParts | Where { $_.Title -eq $WebPartTitle}

#Set the chrome property of the webpart.
$Webpart.ChromeType=”TitleOnly”;

#Save and Publish the web part
$WebPartManager.SaveChanges($Webpart)
$page.CheckIn(“updated Property”)

Happy SharePointing folks !!

Leave a Reply

Your email address will not be published.