Change Hero webpart URLs with PNP PowerShell

Copper Contributor
Hello. Is there a way to modify a URL in the Hero webpart via PnP PowerShell? I've got the properties changed in a variable, but can't find a way to put them back, because set-pnpclientsidewebpart only accepts JSON data, and the changed URL is in the HTML PropertiesData.
 
Thanks for any idea.
 
 
 

 

Connect-PnPOnline -Url https://tenant.sharepoint.com/sites/TestRootSite/TestSite1
 
$webpart=Get-PnPClientSideComponent -Page Home
 
 
foreach($wp in $webpart)
{
if($wp.Title -eq "Hero")
{
$HeroInstanceId=$wp.InstanceId
$heroprops=Get-PnPClientSideComponent -InstanceId $HeroInstanceId -Page Home
$heropropsHTML=$heroprops.HtmlPropertiesData
$test=$heropropsHTML.replace("https://www.pbnet.ro","https://www.bing.com")
 
 
Set-PnPClientSideWebPart -Page "Home" -Identity $HeroInstanceId HtmlPropertiesData $test
Set-PnPClientSidePage -Identity "Home" -Publish
}
}

 

Thanks,
Andrei
0 Replies