Manage Templates
Examples for managing item templates.

Manage Templates

Change Template

1
# Sample Item
2
$sourceTemplate = Get-Item -Path "master:\{76036F5E-CBCE-46D1-AF0A-4143F9B557AA}"
3
# Sample Content
4
$targetTemplate = Get-Item -Path "master:\{93A8866B-972F-4FBF-8FD9-D6004B18C0AF}"
5
6
# Use Get-ItemReferrer to find all items referencing the template, rather than scanning the content tree.
7
$sourceTemplate | Get-ItemReferrer |
8
Where-Object { $PSItem.TemplateId -eq $sourceTemplate.ID -and $PSItem.Paths.IsContentItem } |
9
ForEach-Object {
10
Set-ItemTemplate -Item $PSItem -TemplateItem $targetTemplate
11
}
Copied!

Sitecore Stack Exchange

The following examples are best kept on SSE since it provides more context about the problem being solved.
    Question Find all items based on a template found anywhere in the inheritance chain.
Last modified 2yr ago