Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Compare SXA themes with Sitecore PowerShell Extensions.
# Get tenant theme
# Tenant Theme - change this to your desired ID
$siteTheme = Get-Item -Path "master:" -ID "{A8665181-7D76-4EEE-B5A3-923FD0671205}"
# Basic 2 Theme
$basicTheme = Get-Item -Path "master:" -ID "{B43D07BD-61D5-448F-9323-8B6ACAD4F3C4}"
# Compare scripts for matching name
$siteScripts = $siteTheme.Children["scripts"].Children | Select-Object -Property Name,ID
$siteScriptsLookup = $siteScripts | ForEach-Object { $lookup = @{} } { $lookup[$_.Name] = $_.ID } { $lookup }
$basicScripts = $basicTheme.Children["scripts"].Children | Select-Object -Property Name,ID
$basicScriptsLookup = $basicScripts | ForEach-Object { $lookup = @{} } { $lookup[$_.Name] = $_.ID } { $lookup }
# Report when script is different file size
$matchingScripts = Compare-Object -ReferenceObject $siteScripts -DifferenceObject $basicScripts -Property Name -IncludeEqual |
Where-Object { $_.SideIndicator -eq "==" } | Select-Object -Expand Name
foreach($matchingScript in $matchingScripts) {
$siteScript = Get-Item -Path "master:" -ID $siteScriptsLookup[$matchingScript]
$basicScript = Get-Item -Path "master:" -ID $basicScriptsLookup[$matchingScript]
if($siteScript.Size -ne $basicScript.Size) {
Write-Host "Version mismatch of $($matchingScript)"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment