2

I want to get webpart property value using powershell

$path="C:\Webparts\MyPart.webpart"
$path

[xml]$xmlPath = Get-Content $path

$myrespath = $xmlPath.data.properties.name.UrlWebPart

$myrespath

my webpart has this xml

webParts webPart data properties property name

1 Answer 1

2

If your web part is stored in V3 format (http://schemas.microsoft.com/WebPart/v3) then the following example demonstrates how to get web part property:

$path="c:\Search Box.webpart"

$propertyName = "Title"  #replace to your property name UrlWebPart
[xml]$webPart = Get-Content $path
$property = $webPart.webParts.webPart.data.properties.property | Where-Object {$_.name -eq $propertyName }
$propertyValue = $property.'#text'
$propertyValue  
3
  • cannot convert value system.xml.xmlement to type system.xml.xmldocument
    – Batistuta
    May 5, 2015 at 8:44
  • i cant help if you will not share web part manifest (MyPart.webpart), the example i have provided works just fine for ootb web part (SearcBox) May 5, 2015 at 8:47
  • Its a content search webpart a default one
    – Batistuta
    May 5, 2015 at 8:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.