2.12 Troubleshooting PowerShell Errors

PowerShell Knowledge Scripts may raise such events as "PowerShell script failed to run to completion" or "Error executing PowerShell script." These errors can occur when Knowledge Scripts take a long time to run, or when there is contention for access to the server that executes the PowerShell scripts, MCPSHostServer.exe. The following are recommendations for resolving these issues.

Increase the amount of memory that can be used by MCPSHostServer.exe

Increasing the memory limit reduces the frequency with which the server restarts due to excessive memory usage. Increasing the memory limit also reduces the number of PowerShell errors; each time the server recognizes that it is exceeding its memory usage threshold, the server prevents new jobs from executing until all existing jobs have completed and the server restarts. If existing jobs take a significant amount of time to complete, the waiting jobs may time out and return errors. To increase the amount of memory MCPSHostServer.exe is allowed to use, modify the value of the maxMemoryUsage setting. For more information, see Section 2.10, Changing PowerShell Configuration Settings.

Increase the number of PowerShell execution environments or runspaces that MCPSHostServer.exe can host

The default number of runspaces is five, which means no more than five Knowledge Script jobs can be running simultaneously in the server. If you attempt to run additional jobs, the jobs are held back until runspaces become available as existing jobs complete their iterations. Being held back increases the chance that jobs will time out before running, or before completing their iteration. To increase the number of available runspaces, modify the upperMaxRunspaceHosts setting. For more information, see Section 2.10, Changing PowerShell Configuration Settings.

Note that increasing this value will be beneficial if you are running more than five PowerShell Knowledge Scripts jobs, but even then the benefit may not be significant.