Get web part object with properties

21/10/2012 14:14

 

$serverUrl="https://fastlanessl"
$assembly=[void][reflection.assembly]::LoadWithPartialName("Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")
 
#you have to get the web, where is your web part
 $site = Get-SPSite -Identity $serverUrl
 $web = $site.RootWeb
 
 #initialize the webpart-manager and locate it to the page
 $webpartmanager = $web.GetLimitedWebPartManager("https://fastlanessl/Pages/default.aspx", [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)
 
 #see list of web parts on the page
  $webpartmanager.WebParts
  
  #see selected web part on the page
  $webpart = $webpartmanager.WebParts[0]
  
  #see selected web part properties (web browsable)
  #$webpart|format-table #use from command line
  
  #see concrete property value of wp (e. g.'ConfigurationListuGuid' property)
  $webpart.Title
  $webpart.DisplayTitle
  $webpart.ConfigurationListGuid (#this is custom web browsable property)