I was working on a project where we need to update quite a few Content Editor web parts in a SharePoint 2010 applications. This task was taking longer to do manually but can be done quickly by using a Powershell script. Here is the Powershell which you can use to load data in Content Editor Web Parts:
$CEWebPart = new-object $typeName $CEWebPartType = $CEWebPart.GetType().ToString() if($CEWebPartType -eq “Microsoft.SharePoint.WebPartPages.ContentEditorWebPart”) { if($WebPartContent) # This content would be updated in the Web Part { [string]$content = $WebPartContent.ToString() $oXml = New-Object System.Xml.XmlDocument $WebPartXml = $docXml.CreateElement(“Content”) $WebPartXml.set_InnerText($content) $oXml.AppendChild($WebPartXml) $CEWebPart.Content = $WebPartXml } }
1 comment:
Post a Comment