In SharePoint 2010, we have a feature allowing users to upload and activate sandbox slutions for their particular site collection.
Although sandbox solutions are robust and allow you to specify the resource points you want to allocate to the solution, ensuring the solution is not going to do much harm, there are still concerns with certain solutions making it into the farm. After all, although limited, sandbox solution can cause an error on the page or slow down the system page execution.
Administrators have the ability to block sandbox solutions by registering them as blocked sandbox solutions on the site.
When blocked solution is attempted to be activated – users will get an error, which administrators can choose.
Also, if the solution has already been activated and then blocked, all of the resources which come with the solution will not be executed. For example, if you have a web part which has been provisioned as part of the blocked solution – users won’t be able to work with the web part and when they attempt to re-add it – they will get an error message as per administrator.
In this example I will show you how you can block a solution with PowerShell.
I assume you have a sandbox solution at your disposal, in my scrit below I will be using a solution with name Solution1.wsp. If you have no solutions, download one from codeplex.com
Open SharePoint 2010 Management Shell from the start menu of your web front end and execute the following:
Write-Host "Connecting to User Solutions Host"
$UserCodeSvc = [Microsoft.SharePoint.Administration.SPUserCodeService]::Local
Write-Host "Retrieving sandbox solution signature"
$Signature = [Microsoft.SharePoint.Administration.SPUserCodeService]::
GetSolutionSignatureFromFile($SolutionName)
Write-Host "Creating blocked solution object"
$BlockedSolution = New-Object Microsoft.SharePoint.UserCode.SPBlockedSolution
-ArgumentList ($SolutionName), ($Signature), ("Solution Blocked")
Write-Host "Blocking the solution"
$UserCodeSvc.BlockedSolutions.Add($BlockedSolution)
$UserCodeSvc.Update()
To verify, open Central Administration | System Settings | Manage user solutionsYou will eable to see the blocked solution listed there. You can also try to activate the solution on the site and you will see that associated UI will be greyed out.
Enjoy!