Skip to content

Instantly share code, notes, and snippets.

@AdamNaj
Created June 16, 2019 19:05
Show Gist options
  • Save AdamNaj/282ed9339252bb0614f3845c55f09aeb to your computer and use it in GitHub Desktop.
Save AdamNaj/282ed9339252bb0614f3845c55f09aeb to your computer and use it in GitHub Desktop.
Ret Rendering Variant Roots for all sites
Set-HostProperty -HostWidth 5000
$roots = @()+[Sitecore.Sites.SiteManager]::GetSites() | ? { $_.Properties['IsSxaSite'] } | % { $_.Properties['rootPath'] };
foreach ($root in $roots) {
$site = New-Object -TypeName PSCustomObject
Add-Member -InputObject $site -Name 'path' -Value $root -MemberType NoteProperty
$variants = New-Object -TypeName PSCustomObject
Add-Member -InputObject $site -Name 'variants' -Value $variants -MemberType NoteProperty
$variantFolders = gci "master:$($root)/Presentation/Rendering Variants" | select Name, @{Name = "Path"; Expression={$_.paths.Path}}
foreach($variantFolder in $variantFolders){
Add-Member -InputObject $variants -Name $($variantFolder.Name) -Value $variantFolder.Path -MemberType NoteProperty
}
$site | ConvertTo-Json
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment