Most of Sharepoint developers often deployed farm solutions to Sharepoint web application using Add-SPSolution and Install-SPSolution PowerShell cmdlets. In order to deploy sandbox solutions to on-premise Sharepoint sites we can use appropriate sandbox versions of mentioned cmdlets: Add-SPUserSolution and Install-SPUserSolution. Unfortunately these cmdlets work only on-premise. But how to upload sandbox solution to Sharepoint Online site?
In order to do it we may use Sharepoint Online helper open source project which is hosted on Codeplex. It makes changes in solutions gallery by using client object model. For authentication you have to provide your user name and password for Sharepoint Online site. They will be used for getting authentication cookies which then will be used for making authenticated requests.
At the moment of writing this post it had the following methods for managing sandbox solutions in Sharepoint Online:
- Upload solution
- Activate solution
- Deactivate solution
Unfortunately for complete set of methods it didn’t contain Delete solution method. So first of all we need to add this method to the library. Code is hosted on codeplex with compiled library, so it is quite easy to do:
I also provided patch with this method on project’s site. After that we have all methods we need for managing sandbox solutions on Sharepoint Online site.
Next step is to write PowerShell script for uploading, activating, deactivating and deleting solutions remotely:
In Params.ps1 script we define path to solution on local file system, site url, user name and password for Sharepoint Online:
After that in order to update our solution (deactivate, delete, upload and activate) we may use the following command:
Also we may execute mentioned tasks separately if needed. I hope that this article will be useful and will help you in your work.