How can I check if particular expected item is content and datasources?

foreach($baseItem in $listOfPages) {
  $items += Get-Item $baseItem.Paths.FullPath 
  $items += Get-ChildItem $baseItem.Paths.FullPath -Recurse 

2 Answers 2


It's hard to know what you mean by "is content and datasources".

You can call


that will return true is descendant of /sitecore/content item.

And you can

  • $baseItem.Template
  • $baseItem.TemplateID
  • $baseItem.TemplateName

values to get more information about what kind of item that is.

  • Not always but datasources tend to have no layout. Commented May 26, 2022 at 13:04
  • To be sure if the item is content of page or page item itself Commented May 26, 2022 at 13:10

So you can check if the item is a Content or Datasource using this way also.

$renderingInstance = Get-Rendering -Item $baseItem -Rendering $rendering
    Write-Host "content item"
    Write-Host "datasource item"

You can implement this logic with your code. Hope this will help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.