Tuesday, May 22, 2012

Modify sandbox code/solution execution timeout value using powershell

Default value of sandbox code/solution execution timeout is 30 seconds, there are times when one needs to increase this value to get complex code executed.

To view execution timeout value use following PS command-:

Write-Host $uc.ResourceMeasures["CPUExecutionTime"].AbsoluteLimit

Write-Host $uc.ResourceMeasures["CPUExecutionTime"].ResourcesPerPoint

To Modify above values use the following PS Commands-:

  1. Verify that you meet the following minimum requirements: See Add-SPShellAdmin.
  2. $uc=[Microsoft.SharePoint.Administration.SPUserCodeService]::Local
    $uc.ResourceMeasures["CPUExecutionTime"].AbsoluteLimit = <LimitValue>$uc.ResourceMeasures["CPUExecutionTime"].ResourcesPerPoint = <PointValue>$uc.ResourceMeasures["CPUExecutionTime"].Update()$uc.Update()

    • <LimitValue>
    •  is the new maximum limit value.
    • <PointValue>
    •  is the new number of resources per resource point.

For more information on sandbox solutions refer to the this link.