Last active
December 22, 2018 13:26
-
-
Save AlexKasaku/a881ace9d1303bf3dd84 to your computer and use it in GitHub Desktop.
Filter to determine if an item derives from a particular template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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