How to update WebPart Properties using Powershell in SharePoint 2013/2016?
Hello SharePointers,
Below are the powershell script to update web part properties Target audience Group using Powershell in SharePoint 2013/2016.
$List = $context.Web.Lists.GetByTitle(“employee”)
$context.Load($List)
$context.ExecuteQuery()
$Pages = $List.RootFolder.Files
$context.Load($Pages)
$context.ExecuteQuery()
$Page = $Pages | Where {$_.Name -eq “ViewName”}
$context.Load($Page)
$context.ExecuteQuery()
$mgr = $Page.GetLimitedWebPartManager(“Shared”)
$context.Load($mgr )
$context.ExecuteQuery()
$WebParts = $mgr.WebParts
$context.Load($WebParts)
$context.ExecuteQuery()
$WebPart = $WebParts[0]
$context.Load($WebPart)
$context.ExecuteQuery()
$WebPart.WebPart.Properties[“AuthorizationFilter”] = “Dev Group”
$WebPart.SaveWebPartChanges();
$context.Load($WebPart);
$context.ExecuteQuery();
Happy SharePointing 🙂