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:
- Site Owner
The source code for this post is in my GitHub repo at: https://github.com/colinjwood/CodeCobra/tree/master/CSVProvisioning
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
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:
- 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.