Created
February 27, 2020 10:54
-
-
Save feanz/aeefc47ae6b4ba0c0ff11abb66701644 to your computer and use it in GitHub Desktop.
Copy sitecore site language. A a new language version to all items in a site in sitecore powershell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import-Function CommonFunctions | |
$siteDropdownList = Get-Sites | |
$languageDropdownList = Get-Languages | |
$addVersionBehaviourList = [ordered]@{Overwrite="Overwrite"; Skip="Skip"; Append="Append"}; | |
$addVersionBehaviour = "Append" | |
$props = @{ | |
Parameters = @( | |
@{Name="sourceSitePath"; Title="Choose a source site"; Options=$siteDropdownList; Tooltip="Choose one."}, | |
@{Name="sourceLanguage"; Title="Choose a source language"; Options=$languageDropdownList; Tooltip="Choose one."}, | |
@{Name="destinationLanguage"; Title="Choose a target language"; Options=$languageDropdownList; Tooltip="Choose one."}, | |
@{Name="addVersionBehaviour"; Title="Behaviour if language version exists"; Options=$addVersionBehaviourList; Editor="radio" } | |
) | |
Title = "Copy language" | |
Description = "This script will take a source language and copy items into a target language." | |
Width = 500 | |
Height = 500 | |
} | |
$result = Read-Variable @props | |
if($result -ne "ok") | |
{ | |
Exit | |
} | |
Write-Host "COPY LANGUAGE V1.0" | |
Write-Host "==============================" | |
Write-Host "" | |
Write-Color "Variables:" -Color Magenta | |
Write-Host "" | |
Write-Color "Source path: ", $sourceSitePath -Color White, Yellow | |
Write-Color "Source lang: ", $sourceLanguage -Color White, Yellow | |
Write-Color "Target lang: ", $destinationLanguage -Color White, Yellow | |
Write-Color "Include descendants: ", $includeDescendants -Color White, Yellow | |
Write-Color "Add version behaviour: ", $addVersionBehaviour -Color White, Yellow | |
Write-Host "" | |
Write-Host "==============================" | |
Write-Host "" | |
## Step 1: Get items | |
$itemsToProcess = @() | |
$itemsToProcess += Get-ChildItem -Path master:$sourceSitePath -Recurse -Language $sourceLanguage | |
## Step 2: Copy the source language into a destination language | |
Write-Color "Copying source language ", $sourceLanguage, " to ", $destinationLanguage -Color White, Yellow, White, Yellow | |
$itemsToProcess | Add-ItemVersion -Language $sourceLanguage -TargetLanguage $destinationLanguage -IfExist $addVersionBehaviour | |
Write-Host | |
Write-Color "Copy language complete!" -Color Yellow |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment