How to update SPFX webpart property pane values using Powershell scripts

Lakshmi Priya 0 Reputation points
2023-05-19T04:22:35.07+00:00

I want to update SharePoint 2019 on premises SPFX webpart configuration property pane value using powershell script.

Microsoft 365 and Office | SharePoint | Development
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 40,476 Reputation points Microsoft External Staff
    2023-05-19T08:18:19.17+00:00

    Hi @Lakshmi Priya,

    Per my test, you can refer to following powershell script to update webpart

    $Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
     
    #configuration parameters
    $WebURL="https://sharepoint.Crescent.com"
     
    #Get objects
    $web = Get-SPWeb $WebURL
    $page = $web.GetFile("SitePages/Home.aspx")
    $page.CheckOut()
    $WebPartManager = $web.GetLimitedWebPartManager($Page.ServerRelativeUrl,[System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)
     
    #$WebPartManager.WebParts
    $WebPartManager.WebParts | % { write-host $_.title}
    #Get the Web part
    $Webpart = $WebPartManager.WebParts | Where { $_.Title -eq "Shared Documents"}
     
    #Update Webpart Property
    $Webpart.Title = "Team Documents"
     
    #Save and Publish
    $WebPartManager.SaveChanges($Webpart)
    $page.CheckIn("updated Title Property")
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.