2.15 Troubleshooting PowerShell Errors

Knowledge Scripts in the Exchange2007 category 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 some 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 can use, modify the value of the maxMemoryUsage setting. For more information, see Section 2.14, Changing Configuration Settings.

  • Increase the number of PowerShell execution environments, or runspaces that MCPSHostServer.exe can host. The default number of runspaces is eight, which means no more than eight 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 in this manner 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.14, Changing Configuration Settings.

    Increasing this value will be beneficial if you are running more than eight Exchange2007 Knowledge Script jobs, but even then the benefit may not be significant.

    NOTE:The client’s maxActiveServers configuration option specifies the maximum number of servers that can be active at any time (the default is five). The maxActiveServers configuration value and the UpperMaxRunspaceHosts server configuration value determine the total number of jobs that can be serviced at any one time. You can have more than this number of jobs in the “Running” state in AppManager, but only if some of the jobs are between iterations, and not actually running at the same time.