3

I have an issue with my Sitecore PowerShell script. It runs without errors and returns the expected result when I test it in PowerShell ISE. But when I add exactly the same script to PSE reports and try to run it from the reporting menu, the script throws the following error:

Get-ChilItem: A parameter cannot be found that matches parameter name 'Language'.

Error message

This is the line where the error is thrown:

$itemsToProcess = Get-ChildItem -Path $startPath -Language * -Recurse

What could be causing this error? Why does my script work in the ISE but not in the reporting menu?

2
  • Can you please confirm your exact steps to run that statement via SPE Reporting? Nov 29, 2022 at 12:53
  • My guess is an issue with your start path. It should include the drive such as "master:" Nov 29, 2022 at 13:54

1 Answer 1

1

Please check what value you pass as $startPath, it should start from the database name and be in the format similar to this:

master:/sitecore/content/

I faced this issue in the past and it was caused by the missing database name in the path parameter. The reason it works in PowerShell ISE is that it has pre-selected context database and root path that can be used if you omit it in the script itself:

Context DB and path

However, when you run the same script as a report, it does not have a default database to fallback to and throws this error.

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.