Skip to content

Instantly share code, notes, and snippets.

@AlexKasaku
Last active December 22, 2018 13:26
Show Gist options
  • Save AlexKasaku/a881ace9d1303bf3dd84 to your computer and use it in GitHub Desktop.
Save AlexKasaku/a881ace9d1303bf3dd84 to your computer and use it in GitHub Desktop.
Filter to determine if an item derives from a particular template
Function Where-TemplateDerives {
param(
[Parameter(Mandatory=$true,ValueFromPipeline=$true)]
[Sitecore.Data.Items.Item]$Item,
[Parameter(Mandatory=$true,Position=0)]
[string]$TemplateID
)
process {
if ($Item) {
$template = [Sitecore.Data.Managers.TemplateManager]::GetTemplate($Item)
if ($template.DescendsFromOrEquals($TemplateID)) {
$Item
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment