Tuesday, November 20, 2012

Get Web Part Properties for a page with PowerShell script

It happens when you have a problem with a webpart in one of your SharePoint environments in need to debug to see what are the properties of this webpart, this PowerShell script can help:


#Add-PSSnapin Microsoft.SharePoint.PowerShell

$SiteUrl = "http://www.yoursite.com"
$pageURL = "Pages/default.aspx"

$site = New-Object Microsoft.SharePoint.SPSite($SiteUrl)
$psite = New-Object Microsoft.SharePoint.Publishing.PublishingSite($site)
$web = Get-SPWeb $SiteUrl
$pweb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)

$wpm = $web.GetLimitedWebPartManager($pageURL, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)

#List all the web parts
$wpm.WebParts | ft

#Get the details of the first web part
$wp = $wpm.WebParts[0]
$wp


No comments:

How to Install and Use RTSP Simple Server

  How to Install and Use RTSP Simple Server   1.   Create a folder to store the app mkdir /etc/rtsp-server cd /etc/rtsp-server   2.  Downloa...