Deactivate Sandbox Solution with PowerShell in Office 365

Standard

In recent days Microsoft have released a Visual Studio solution which allows you to control SharePoint Online sandbox solutions.

The solutions builds a DLL file which can be imported as a PowerShell module and then you can use it to Upload, Activate, Deactivate and Delete solutions from a SharePoint Online site collection.

The provided documentation is great however during my own testing I found that solutions were not getting deactivated in my SharePoint Online 2010 site collections.

You will most likely find your 2010 site collection is actually in SharePoint 2013 version (15.0+) however if you use the -environment “MSO_2010” presents an error.  If you change this to -environment “MSO_2013” you will find it works even though you site collection appears to be in 2010.

Click here to download the solution from the Microsoft code website.  You will have to Build the solution to get the DLL as the one from the download does not work.  Alternatively you can download it from here.

Happy PowerShell’ing

Import Module

Import-Module “c:Contoso.Solution.Cmdlets.dll”

Upload Solution

upload-solution -username “admin@xyz.onmicrosoft.com” -password “XXXX” -siteurl “https://xyz.sharepoint.com” -solutionfilepath “C:\Example.wsp” -environment MSO_2013

Activate Solution

activate-solution -username “admin@xyz.onmicrosoft.com” -password “xxxx” -siteurl “https://xyz.sharepoint.com” -solutionid “5BC8D9A8-AE5A-4CF8-8D25-03B239818193” -environment MSO_2013

Deactivate Solution

deactivate-solution -username “admin@xyz.onmicrosoft.com” -password “xxxx” -siteurl “https://xyz.sharepoint.com” -solutionid “5BC8D9A8-AE5A-4CF8-8D25-03B239818193” -environment MSO_2013

Delete Solution

delete-solution -username “admin@xyz.onmicrosoft.com” -password “xxxx” -siteurl “https://xyz.sharepoint.com” -solutionid “5BC8D9A8-AE5A-4CF8-8D25-03B239818193” -environment MSO_2013

1stImageBlogPost---Extended