Online Training On SharePoint

Tuesday, 13 December 2011

Updating Content Editor Web Parts using Powershell

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”)
# This content would be updated in the Web Part
              [string]$content = $WebPartContent.ToString()
              $oXml = New-Object System.Xml.XmlDocument
              $WebPartXml = $docXml.CreateElement(“Content”)
              $CEWebPart.Content = $WebPartXml
Post a Comment
Related Posts with Thumbnails