In our project, we have a situation that we need to update the property of a web part. Since our site is in production, we couldn't recreate the site. The web part is on nearly every welcome page and many pages are created, so we could not manually change the property. So I decided to write the Powershell script.

The following is the procedure to update the web part property using Powershell commands.

The following is the complete Powershell script.

$site = Get-SPSite "SiteCollectionURL"
$webcoll = $site.AllWebs
# Step through each web in site collection
foreach ($web in $webcoll) {
    # Get the root folder
    $folder = $web.RootFolder    
    # Get the welcome page
    $welcomepage = $folder.WelcomePage
    $file = $web.GetFile("$welcomepage")    
    $file.CheckOut()    
    $wpm = $web.GetLimitedWebPartManager("$welcomepage", [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)  
    foreach ($webpart in $wpm.WebParts) {
        if ($webpart.MyUniqueProperty) {
            if (!$webpart.MyUniqueProperty) {
                $webpart.MyUniqueProperty = $MyUniquePropertyValue # Value which need to be Set/Update
                $wpm.SaveChanges($webpart)
            } # First If
        } # Second If
    } # Foreach    
    $file.CheckIn("Updated/Set property of webpart", 1)
    $file.Publish("Updated/Set property of webpart")
    $site.Dispose()
} # foreach

I hope this will help you. Thanks. Feel free to discuss this.