0

I've created multiple custom reports for content managers. They all run as expected in the Sitecore Powershell ISE.
When I save them in Reporting Tools and attempt to run I am getting errors.
The first error was due to the relative -Path so I added the master: prefix and that fixed it.

The error I'm stuck on is "Get-ItemTemplate : Current Sitecore database cannot be established, current location is not within a Sitecore content tree"

Here is the relevant part of the report script. It fails on the last line:

$path = $root.Paths.FullPath
$pathtouse = "master:" + $path
#Get Items
$items = Get-ChildItem -Path $pathtouse -Recurse
#For each item check templates
foreach($item in $items){
    $template = Get-ItemTemplate -ID $item.ID
}
2

1 Answer 1

1

My guess is that you need to add the -Path parameter when using -ID or instead just use -Item $item. The database is not known when calling the Get-ItemTemplate command.

https://doc.sitecorepowershell.com/appendix/common/get-itemtemplate

Get-ItemTemplate -Item $item 
1
  • You are right on with the suggestion. Appreciate the quick help. Get-Template -Item $item did the trick. Jul 15, 2021 at 19:44

Your Answer

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

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