Skip to content

Instantly share code, notes, and snippets.

@agehlot
Last active September 24, 2022 08:33
Show Gist options
  • Save agehlot/423929eea587b448fed413c7c5e60bef to your computer and use it in GitHub Desktop.
Save agehlot/423929eea587b448fed413c7c5e60bef to your computer and use it in GitHub Desktop.
Sitecore PowerShell script to recursively reset the base template of all items under given path.
Get-ChildItem "/sitecore/templates/Feature/Fortune" -Recurse |% {
$currentTemplate = $_
$templateIds |% {
$currentTemplate."__Base Template" = $currentTemplate."__Base Template" -Replace "$($.ID)|", ""
$currentTemplate."__Base Template" = $currentTemplate."__Base Template" -Replace "$($.ID)", ""
}
}
$templateIds |% {
$deletingTemplate = $_
Get-ChildItem "/sitecore/content" -Recurse | ? { $_.TemplateName -eq $deletingTemplate.Name } | Remove-Item
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment