PowerShell and CSOM: Tool to Import Design Package WSP with activation of required feature for SharePoint Online-O365


This is my initial article to address the challenges around automation of SharePoint Online deployment.
Below artifacts can be developed through this technique,

  • List Definition
  • List Instance
  • Web part development
  • Template Development
  • JS Link webpart development
  • Remote Timer Job
  • Remote Event Handler
  • etc.
You can combine any set of above artifacts in to a WSP solution.

Tool Description

This tool is responsible for activating the mandatory features for any site other than Publishing and Installing or Upgrading the WSP Solution to SPO O365 tenant site collection.

Below are the features activated using this tool,

1. SharePoint Server Publishing Infrastructure

2. SharePoint Server Publishing

You can also extend the logic for activation of other feature by calling below,

Enable-SPOFeature -sSiteColUrl $SiteURL -spoCtx $Context -sFeatureGuid $FeatureGuidServerPublishing -IsSiteScope $False
Use below parameters while calling method,
$SiteURL – site collection URL
$Context – Context of the site
$sFeatureGuid – Guid of feature to be activated
$True or $False – is site collection level feature


Download Source

Click here to download Source

Authentication and Execution Model

Authentication and Execution Model
As depicted in above model diagram shows how PowerShell based tool help to authenticate, connect to SPO and on validation it helps to execute the CSOM based commandlets and deploy the WSP to perform deployment of different artifacts as packaged. Below are major component as depicted in diagram,
A. SharePoint Online Mangement Shell
B. Authentication component – while connecting to SharePoint Online tenant
C. Validated Admin enable to process the execution to SPO
D.SharePoint Tenant – Site Collection  Targeted destination for deployment

Run Execution Command

Below is the command will be helpful to execute the tool. Kindly modify the parameters before execution,

.\ApplyDesignPackageInstalltionAndUpgradeWSP.ps1 -User admin@xxxxxx.onmicrosoft.com -SiteURL "https://xxxxxx.sharepoint.com/sites/xxxxxx" -wspFullFilePath "C:\Amjad\<WSPBuildName>.wsp"  -WspFileName "<WSPBuildName>.wsp" -wspPackageName "<WSPBuildName>" -majorVersion 1 -minorVersion 0
 Parameters details are as below,

Script can accept 7 parameters from the command line#

# User – mandatory – Administrator login ID for the tenant we are querying

# SiteURL – mandatory – Destination Site URL for the tenant we are querying

# wspFullFilePath – mandatory – Path of WSP location to upload from

# WspFileName – mandatory – Name of WSP file

# wspPackageName – Optional – WSP Package Name for Solution Gallery

# majorVersion – Optional – majorVersion of the Build demployment or upgrade

# majorVersion – Optional – minorVersion of the Build demployment or upgrade#


Hope this article helps.