-1

I need to copy item field data from en language to all other available languagesin all versions. Any powershell script of achieving this.

0

Probably the below script can help you. The comments are added to the script to make each step obvious. You can do modifications to it to suit your purpose -

#Get all language versions defined in System/Languages

$languages = Get-ChildItem /sitecore/System/Languages -recurse | Select $_.name | Where-Object {$_.name -ne "en"} | Select Name

#Ensuring correct items are updated by comparing the template ID 

$items = Get-ChildItem -Path "/sitecore/<your item location>" -Recurse | Where-Object {'<item template id>' -contains $_.TemplateID}

#Bulk update context to improve performance

New-UsingBlock (New-Object Sitecore.Data.BulkUpdateContext) {

    foreach($item in $items){   

               foreach($language in $languages){

                    $languageVersion = Get-Item -Path $item.Paths.Path -Language $language.Name

                    #Check if language version already exists

                    if($languageVersion -eq $null){

                        Write-Host "Creating "$language.Name" version for "$item.Name

                        Add-ItemLanguage -Item $item -Language "en" -TargetLanguage $language.Name -IfExist OverwriteLatest                     

                    }
                } 
            }
        }

The script is also available at my blog.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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