I am trying to remove a base template if found and add a different base template if not found. In the code below the standard template is never found even though I know its there. Is it because I'm trying to find the template on a template? Should I use descendants somehow? I've commented the remove and add for now...
$baseL = Get-Item -Path "master:\sitecore\Templates\Toro\Foundation\Language\_Language Fallback";
$baseS = Get-Item -Path "master:\sitecore\templates\System\Templates\Standard template";
cd master:\Templates\Toro\Feature\;
Get-ChildItem -recurse | ForEach-Object {
if ($_.TemplateName -eq 'Template') {
# Get the direct template for the item, then check to see if it has a certain base template based on the template's ID
$hasSTemplate = [Sitecore.Data.Managers.TemplateManager]::GetTemplate($_).InheritsFrom($baseS.ID);
# Remove Standard Template
if ($hasSTemplate) {
echo "Yep, it has that template."
#Remove-BaseTemplate -Path "master:/sitecore/content/User Defined/Page" -TemplateItem @($baseS)
}
# Get the direct template for the item, then check to see if it has a certain base template based on the template's ID
$hasLTemplate = [Sitecore.Data.Managers.TemplateManager]::GetTemplate($_).InheritsFrom($baseL.ID);
# Add Language Template
if ($hasLTemplate –eq $FALSE) {
echo "Yep, it does not have that template."
#Add-BaseTemplate -Path "master:/sitecore/content/User Defined/Page" -TemplateItem @($baseL)
}
Write-Host $_.FullPath
}
};