I am running a script and I am using loop concept to get certain data. But a session timeout error was encountered during the script execution and the script stopped running.

Issue: A script needs to be executed in the session before the variable value can be inspected.

I am new to using PowerShell script and have no idea how to resolve this kind of error.

Here, I have attached a demo script and error.

enter image description here enter image description here enter image description here

Thanks in Advance. Manish

  • Can you share the screenshot of error? Jul 25, 2022 at 12:19
  • I have attached screenshot in description with session tooltip error. Script randomly stopped running after 25000. Jul 25, 2022 at 12:36
  • and what is your Sitecore version? Jul 25, 2022 at 12:49
  • It's a Sitecore 8.2 (rev. 180406) Jul 25, 2022 at 13:19

2 Answers 2


I believe there is some logic which is clearing the session at specific interval, and we also faced same type of issue in past and we just increased the interval for below setting, and it worked for us. If you increase it for 30 minutes on temporary basis it should help.

<agent type="Sitecore.Tasks.DatabaseAgent" method="Run" interval="00:03:00" name="Master_Database_Agent">

This issue typically happens when the session object cached on the server in memory is lost. Most often this happens after the script completes or the application pool in IIS recycles.

You may want to design your script to support restarting from the last completed step. For example you could update an item or write progress to a database table.

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.