0
votes

My goal is to get an export of all webpart properties (including custom props) along with their values, from a page (urls provided through CSV).

I am following this approach: https://www.c-sharpcorner.com/article/retrieve-webparts-from-page-using-csom-with-powershell-for-s/

I am able to access all webparts sitting on a page as I can print their ID and Name, but getting an error in:

$ctx.Load($webpart.WebPart.Properties)
$ctx.ExecuteQuery() 

Error:

Exception calling "ExecuteQuery" with "0" argument(s): "Field or property "Properties" does not exist."

Appreciate your inputs / thoughts. Thanks.

1
Is there any update ?Jerry

1 Answers

0
votes

SharePoint 2010 CSOM library didn't have the property "$webpart.WebPart.Proerties", if you can access the SharePoint Server, use SharePoint Server Object Model in PowerShell instead:

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