Tuesday, August 12, 2014

Provision SharePoint ClientWebPart custom properties through PowerShell

Currently developing on projects where a lot of SharePoint provider hosted apps are involved. App parts with custom properties are used to integrate them on SP webpages and I needed to provision those properties through PowerShell.
Not really rocket science, but couldn't find anything on the web and needed to decompile to find the solution, so decided to drop it here. The ClientWebPartProperty does the job:

$webpart = New-Object Microsoft.SharePoint.WebPartPages.ClientWebPart
$newProperty = New-Object Microsoft.SharePoint.WebPartPages.ClientWebPartProperty
$newProperty.Name = "nameoftheproperty"
$newProperty.Value = "valueoftheproperty"
$webpart.Properties.Add($newProperty)

Don't forget the set the FeatureId, WebPartName and ProductWebId properties as explained here.

3 comments:

  1. Your blog is awfully appealing. I am contented with your post. I regularly read your blog and its very helpful. If you are looking for the best For Sale By Owner in ACT, then visit Sale By Home Owner. Thanks! I enjoyed this blog post.

    ReplyDelete
  2. Thanks for posting this code. If you're researching for sale by owner houses for sale, we can help with that. In any case, thanks for posting the information above.

    ReplyDelete
  3. Great article by the great author, it is very massive and informative but still preaches the way to sounds like that it has some beautiful thoughts described so I really appreciate this article. Get for more information Call Girls daman

    ReplyDelete