PnP Provisioning PowerShell, Site Scripts or CSOM scripts – which one to use and when?

Posted by

There are various approaches to plan and automate the process for Site creation and management of SharePoint Online Sites. In this blog we will look at these options and how to use with a best possible approach.

Pnp Provisioning PowerShell is a great way to automate creation of SharePoint assets through an xml or pnp template file using PowerShell. Similarly, Site scripts and site design allows us to create Site using JSON templates and also allows call to any Provisioning automation scripts or use a Template for custom implementation. SharePoint CSOM is also a way to apply extensive custom changes onto a site. If you would like to know more about each of these individual approaches, check the blog below

1. PnP PowerShell and SPO PowerShell

2. Site Scripts and Site Design

3. SharePoint CSOM scripts

So the most important question is now when to implement what and when. Actually there are so many scenarios that play into it that there is no correct answer to it. Hence in this blog, I will try to put provide some pros and cons for each of them and provide a plan to consider the best options when considering an approach.

PnP PowerShell & SPO PowerShell

One of the powerful admin tool is PowerShell. It has a greater extensibility with regards to modules and also supports C# method implementation with proper dll references.

PnP PowerShell adds to that and allows Admins (both Tenant and Site Collection Admins) to manage and implement automation workloads from scripts

Pros:

1. Easy installation and cmdlet usage

2. No hosting requirements besides a system where PowerShell (>5.0) is installed

3. One Line cmdlets for most complex SharePoint implementation scenarios

3. Error handling and tracing support

Cons:

1. Parallel tasking for more data intensive operations is challenging

2. Not much options for extensibility besides the the ones provided

3. Not all Site Operations such as taxonomy field updates (unless do XML schema update) are supported yet

Site Scripts and Site Designs

This is the latest way of creating and applying changes onto modern sites using a custom template called Site Designs. Site designs extend the OOB templates allowing to add more site assets than provided.

Pros:

1. Simple scripting process (use JSON) to create the script file for site assets and apply features

2. Allows associating a custom theme to the template.

3. Allows extensibility to more complex process by supporting calls to Flow

Cons:

1. No support yet for complex structures such as taxonomy fields, web part implementation, content type support

2. No hooks or support yet to wait for custom provisioning process to finish

SharePoint CSOM scripts

SharePoint CSOM allow us to programmatically script elements using the SharePoint object model. This allows us to do script elements that can pertain to particular elements on the site and have more extensibility into component handling.

Pros:

1. The most extensive model available for SharePoint Online that allows us to add/change elements

2. Work on components that need complex provisioning requirements such as dynamic Navigation components, Library and Site settings, default folders etc. More info at here.

3. Provides extensibility for the above two options through explicit referencing when needed

Cons:

1. Need additional hosting outside of Office 365 via Azure Function, App or equivalent

2. Need maintenance for any breaking changes

The Verdict:

Considering the three options above, each of them have their strengths and weaknesses. The best approach would be plan and use them according to the requirements. Below are few recommendations to combine them for each type of elements in SharePoint Sites.

Note: The options listed below are valid as of Nov 2018 and might change as they are updated from MS
Scope\Tools PnP and SPO PowerShell SharePoint Online CSOM Site Scripts
Site Collections Yes Yes No
Site / Web Yes Yes No
Office 365 groups Yes Yes No
List/Library Yes Yes Yes
Theme Yes Yes Yes
List Item Yes Yes No
Content type/Fields/Views Yes Yes Yes
Client Side Pages Yes Yes No
Folders Yes Yes No
Hub settings Yes Yes No
App Deployments Yes Yes Limited
List Configuration Limited Yes No
Site Settings Yes Yes Limited
Taxonomy Store No Yes No
Taxonomy Fields No Yes No
Navigation Limited Yes Limited
Site Search Settings Yes Yes No
Enterprise Search Yes Yes No
Security Yes Yes Yes

Conclusion

In this blog we compared the various options for Site Provisioning and how those could be used to create and prepare site components.

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s