Provision multiple SharePoint Online site collections with PnP PowerShell

This blog post follows on from my previous blog post on basic SharePoint site collection provisioning in Office 365: https://colinjwood.wordpress.com/2017/12/14/create-a-sharepoint-site-collection-in-an-office-365-tenant-with-pnp-powershell/

In this post I will go through how you can provision multiple site collections in an Office 365 tenant using a csv file which specifies configuration information about each site collection:

  • Url
  • Site Owner
  • Template
  • Timezone
  • Title

The source code for this post is in my GitHub repo at: https://github.com/colinjwood/CodeCobra/tree/master/CSVProvisioning

The script is here: https://github.com/colinjwood/CodeCobra/blob/master/CSVProvisioning/createSiteCollectionsFromCSV.ps1

I have included an example csv file in the repo that the script uses. It needs to be located in ‘C:\\temp’ on local machine running the script. This step could also be automated so that the csv file is downloaded from GitHub to the temp folder on the local machine, then used by the script for site collection provisioning. I use this technique in one of my other GitHub repos here at OnePlace Solutions to provision Site Columns in SharePoint. The provisioning xml is downloaded then used by the PowerShell script : https://github.com/OnePlaceSolutions/EmailColumnsPnP/blob/master/installEmailColumns.ps1

image

To run the SharePoint site collection provisioning script perform the following:

  • Create your csv file with all the site collection configuration information based on the example csv provided and locate it in c:\temp on your machine running the PowerShell script.
  • Run Windows PowerShell and copy and paste the following command at the command prompt:
Invoke-Expression (New-Object Net.WebClient).DownloadString(‘https://raw.githubusercontent.com/colinjwood/CodeCobra/master/CSVProvisioning/createSiteCollectionsFromCSV.ps1')
  • Enter the url of your SharePoint online tenant:

image

  • The site collections will be provisioned in your tenant based on the configurations provided in the csv file. To confirm progress check the Site list in the SharePoint Admin are of your tenant.

This gives you an example of how to configure all or some of the site collections in your Office 365 tenant and create them with one script. This could form the basis of any scripts you write to perform site collection provisioning.

Advertisements

One thought on “Provision multiple SharePoint Online site collections with PnP PowerShell

  1. Pingback: Create a SharePoint site collection in an Office 365 Tenant with PnP PowerShell | Colin Wood

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 )

w

Connecting to %s