in

Dot Net Mafia

Group site for developer blogs dealing with (usually) Ionic, .NET, SharePoint, Office 365, Mobile Development, and other Microsoft products, as well as some discussion of general programming related concepts.

This Blog

Syndication

Archives

Corey Roth [MVP]

A SharePoint MVP bringing you the latest time saving tips for Ionic, SharePoint, and Office 365.

Adding and Deploying Sandboxed Solutions Using PowerShell

One of my most popular posts on DotNetMafia.com is my post on using PowerShell to add and deploy SharePoint solution packages (.wsp files).  However, in that post, I never went in detail in deploying sandboxed solutions.  Today, I want to talk about that and show you what you need to know.  I started by using Visual Studio 11 to build a sandboxed solution using the new Visual Web Part.

To get started with PowerShell, run the SharePoint 2010 Management Console located in your Microsoft SharePoint 2010 Products folder on your start menu.  This automatically loads the Microsoft.SharePoint.PowerShell snappin so that we can execute SharePoint commands.  To install a solution we will use the Add-SPUserSolution command. It takes two parameters.  Specify –literalpath, which is the path to the solution file.  One thing that is different is that you must specify the full path to the file for some reason.  You then need to specify the URL to the site collection with the –site parameter.  Here is an example.

Add-SPUserSolution –LiteralPath c:\code\SandboxedSolutionProject.wsp –Site http://sp2010/sites/sandbox

It looks like this in PowerShell.  If it executes successfully, you’ll just be returned to the command prompt.

PowerShellAddSPUserSolution

We can now see our .wsp file in the solution gallery.

SolutionGalleryNotActivated

We can see the solution package but note that it is not activated.  For that, we need Install-SPUserSolution.  It’s parameters are similar.  We use –Identity with the name of the solution package (minus the path) and the –Site parameter with the URL of the site collection again.

Install-SPUserSolution –Identity SandboxedSolutionProject.wsp –Site http://sp2010/sites/sandbox

PowerShellInstallSPUserSolution

Once activated you can confirm it in the solutions gallery.  You can now activate features as desired (using PowerShell if you want).

SolutionGalleryActivated

At some point, you might want to remove your solution.  We can do that with PowerShell as well.  First, we need to deactivate the solution using Uninstall-SPUserSolution.  It takes the exact same parameter as Install-SPUserSolution.

Uninstall-SPUserSolution –Identity SandboxedSolutionProject.wsp –Site http://sp2010/sites/sandbox

PowerShellUninstallSPUserSolution

Many of these commands may prompt you with an “Are you sure?” type prompt.  You can skip this prompt by adding a –confirm parameter.  Now, the last step is to remove the .wsp file from the solution store.  For that, we’ll use Remove-SPUserSolution.  It uses the –Identity and –Url parameters like the other commands.  Just pass the name of the solution package along with the URL of the site collection.

Remove-SPUserSolution –Identity SandboxedSolutionProject.wsp –Site http://sp2010/sites/sandbox

PowerShellRemoveSPUserSolution

Now the solution is gone from the Solutions gallery.  I like to automate everything that I can so these simple PowerShell commands should help if you are working with sandboxed solutions.

Comments

 

SharePoint Daily » Blog Archive » Whose SharePoint is It?; Microsoft vs. Google: Social; Windows 8 Boots ‘Too Quickly’ said:

Pingback from  SharePoint Daily  » Blog Archive   » Whose SharePoint is It?; Microsoft vs. Google: Social; Windows 8 Boots ‘Too Quickly’

May 23, 2012 7:53 AM
 

SharePoint Daily said:

YAY, the sun is out. - Dooley Top News Stories Whose SharePoint is It Anyway (AIIM) Lately, I’ve

May 23, 2012 7:58 AM
 

Max said:

I was able to activate solution which includes empty content type definition. But as soon as I add Feature Event Receiver without any code in it (all methods are commented) then this solution fails with the error Install-SPUserSolution : Sandboxed code execution request failed. Could you please help me with this error?

December 12, 2012 10:21 AM
 

Whose SharePoint is It?; Microsoft vs. Google: Social; Windows 8 Boots ‘Too Quickly’ – Bamboo Solutions said:

Pingback from  Whose SharePoint is It?; Microsoft vs. Google: Social; Windows 8 Boots ‘Too Quickly’ – Bamboo Solutions

June 6, 2016 2:57 AM
 

Whose SharePoint is It?; Microsoft vs. Google: Social; Windows 8 Boots ‘Too Quickly’ – Bamboo Solutions said:

Pingback from  Whose SharePoint is It?; Microsoft vs. Google: Social; Windows 8 Boots ‘Too Quickly’ – Bamboo Solutions

June 7, 2016 10:11 PM

Leave a Comment

(required)  
(optional)
(required)  
Add

About CoreyRoth

Corey Roth is an independent SharePoint consultant specializing in ECM, Apps, and Search.
2018 dotnetmafia.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems