Get The Load Balancing Setting In Sandboxed Solution Execution Using Powershell

Load Balancing in Sandboxed Solution Management is managed in two ways.
  1. All Sandboxed code runs on the same machine as a request.
  2. Requests to run Sandboxed code are routed by solution affinity.
To get how the execution of code in Sandboxed Solutions is distributed across the Servers, using PowerShell, please use the command given below.
$sandcode=[Microsoft.SharePoint.Administration.SPUserCodeService]::Local
$sandcode.UseLocalServerOnly

If it returns true, this means that it's an option 1 = 'All Sandboxed code runs on the same machine as a request'.

If it returns false, this means that it's an option 2 = 'Requests to run Sandboxed code are routed by solution affinity'.

I hope this helps.