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.

SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,802 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 33,641 Reputation points Microsoft Vendor
    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.