Created
February 15, 2023 19:33
-
-
Save michaellwest/ca64f46d4bd9833a5cc3b7fb4eec50a0 to your computer and use it in GitHub Desktop.
Sitecore PowerShell Extensions Content Migrator for all sites using SXA Get-AllSxaSite.
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
Clear-Host | |
Import-Module -Name SPE -Force | |
$scriptDirectory = & { | |
if ($psISE) { | |
Split-Path -Path $psISE.CurrentFile.FullPath | |
} else { | |
$PSScriptRoot | |
} | |
} | |
. "$($scriptDirectory)\Copy-RainbowContent.ps1" | |
$secret = "SOME_SECRET" | |
$props = @{ | |
"Username" = "RemotingUser" | |
"SharedSecret" = $secret | |
} | |
$sourceSession = New-ScriptSession @props -conn "https://scmsx.prda.sxp.local" | |
$destinationSession = New-ScriptSession @props -conn "https://scmsx.int.sxp.local" | |
$copyProps = @{ | |
"WhatIf"=$true | |
"CopyBehavior"="CompareRevision" | |
"Recurse"=$true | |
"RemoveNotInSource"=$true | |
"ClearAllCaches"=$false | |
"LogLevel"="Normal" | |
"CheckDependencies"=$false | |
"BoringMode"=$false | |
} | |
$copyProps["SourceSession"] = $sourceSession | |
$copyProps["DestinationSession"] = $destinationSession | |
$rootIds = @() | |
$rootIds = Invoke-RemoteScript -ScriptBlock { | |
Import-Function -Name Get-AllSxaSite | |
$sites = Get-AllSxaSite | |
$rootIds = [System.Collections.ArrayList]@() | |
foreach($site in $sites) { | |
if(!$site.Children["Home"].Paths.Path.StartsWith("/sitecore/content/BrandName/")) { continue } | |
$rootIds.Add($site.Children["Data"].Id.ToString()) > $null | |
$rootIds.Add($site.Children["Home"].Id.ToString()) > $null | |
$rootIds.AddRange($site.Children["Media"]["AdditionalChildren"].Split("|")) > $null | |
} | |
$rootIds | |
} -Session $sourceSession | |
foreach($rootId in $rootIds) { | |
Copy-RainbowContent @copyProps -RootId $rootId -ExcludeId $excludeIds | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment