Skip to content

Instantly share code, notes, and snippets.

@michaellwest
Created February 15, 2023 19:33
Show Gist options
  • Save michaellwest/ca64f46d4bd9833a5cc3b7fb4eec50a0 to your computer and use it in GitHub Desktop.
Save michaellwest/ca64f46d4bd9833a5cc3b7fb4eec50a0 to your computer and use it in GitHub Desktop.
Sitecore PowerShell Extensions Content Migrator for all sites using SXA Get-AllSxaSite.
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