0

I have a few sites with the same page layout but different content. On these sites is text webpart which I want to be edited dynamically from other place. Is it possible to connect this text webpart to some other webpart placed on different site and clone the content automatically? Or maybe it is better to use PowerShell with Azure pipeline script? Any other solution?

enter image description here

2 Answers 2

0

You can try pnp powershell, not sure if it can be executed in Azure pipeline script.

My test script for your reference: This part is to get content in text web part,you could add filter condition to get the target text web part,the ControlType of text web part is 4.

    $username = "[email protected]"
    $password = "pwd"
    $cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $userName, $(convertto-securestring $Password -asplaintext -force)
    Connect-PnPOnline -Url https://haiqiwu.sharepoint.com/sites/dev -Credentials $cred 
    $page = Get-PnPClientSidePage -Identity "wikipage.aspx"         
    $webParts = $page.Controls  
    foreach ($webpart in $webparts) {  
        Write-Host "ControlType "  $webpart.ControlType 
        Write-Host "Title "   $webpart.Title  
        Write-Host "Type "   $webpart.Type
        Write-Host "Text"   $webpart.Text     #content in text web part          
    }  

After you get the content,you could set it to the text web part like this:

    $content = $sourcewebpart.Text;
    $targetwebpart.Text = $content;
    $targetpage.Save()  
    $targetpage.Publish()
0

I also made some PS script. It gets information from list field on one site and place it on other site

List have columns: Title (site name), Link, processDesc (text)

$sourceSite= "https://XXX.sharepoint.com/sites/Products"  
Connect-PnPOnline -Url $sourceSite-PnPManagementShell

$listItems= Get-PnPListItem -List ProductSites -Fields "Title","Link", "processDesc"

#List content
foreach($element in $listItems){  
   Write-Host "Title" : $element["Title"]  
   Write-Host "URL" : $element["Link"]  
   Write-Host "Process" : $element["processDesc"]  
   Write-Host "---------------------------"  
} 

foreach($element in $listItems){

$siteURL = $element["Link"]  
Connect-PnPOnline -Url $targetSiteURL -PnPManagementShell

#Add new text webpart
Add-PnPClientSideText -Page $targetPage -Text $element["processDesc"]
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.