modern-sharepoint-site-provisioning.jpg

Provisioning Modern SharePoint Site Collections

In Office 365, we recently had to provision multiple SharePoint Online site collections that included both modern team and modern communication sites. This is a summary of the steps we took to provision the new site collections in our customers’ O365 tenant.

This article includes example PowerShell scripts that you can use to create multiple new site collections. Some of these steps are well documented and easy to find, but this article summarizes all the steps in one place as well as how to be certain you are using the correct template. Hopefully, these steps will help to get site collections provisioned very fast so the real work can begin..

Step 1 – Get the List of Templates

First, get the current List of Templates from the O365 tenant that you intend to create the new site collections in, so you can use the proper site template name in the ps1 script.  This is the fastest way to find the template name and be certain you are using the correct template for your site collection.

Place the following 3 lines of code into a PowerShell .ps1 file and run from SharePoint Online Management Shell. Replace the SharePoint Online Global Administrator username on the first line where it shows {insert SharePoint Online Global Admin username here} and also replace the {tenant name} in the second line before running against your tenant.

$admin = '{insert SharePoint Online Global Admin username here}'

Connect-SPOService -Url https://{tenant name}-admin.sharepoint.com -credential $admin

Get-SPOWebTemplate 

Running this code will display output like this in SharePoint Online Management Shell:

C:\Users\krist\AppData\Local\Microsoft\Windows\INetCache\Content.MSO\1E883106.tmp

For the modern team site, the template name “STS#3” is seen in the first row above. The modern communication site template name is “SITEPAGEPUBLISHING#0” which can be seen on the third row from the bottom. All the available templates for your tenant will be listed.

Note: The templates all have a default locale id of 1033, which is English – United States. The CompatibilityLevel of 15 indicates the version of the template which are SharePoint 2013 templates.

Step 2 – Provision the Sites

Next, provision the actual sites using similar code to the example below. Add the example code into a PowerShell file and run it from SharePoint Online Management Shell after first making the following changes:

  • Insert the SharePoint Online Global Administrator username on the first line where it shows {insert SharePoint Online Global Admin username here}.
  • You also need to update/add a line for each site collection you want to provision with the correct Url, Title, Template, and StorageQuota. (The -NoWait parameter ensures the site gets created immediately.)
  • Replace the {tenant name} in each Url within the script before running against your tenant.
$admin = '{insert SharePoint Online Global Admin username here}' 
Connect-SPOService -Url https://{tenant name}-admin.sharepoint.com -credential $admin  
  
New-SPOSite -Url https://{tenant name}.sharepoint.com/sites/latam -Owner $admin -StorageQuota 20000 -Title "LATAM Team" -Template "STS#3" -NoWait 
New-SPOSite -Url https://{tenant name}.sharepoint.com/sites/io -Owner $admin -StorageQuota 5000 -Title "International Operations" -Template "SITEPAGEPUBLISHING#0" -NoWait 

Note: The first new site collection is a Modern Team Site. The second new site collection is a Modern Communication Site.

You can add as many new sites as needed by adding a new line with the New-SPOSite PowerShell cmdlet and appropriate parameter values.

Be sure to account for adequate storage space/quota size for each site collection. The -StorageQuota parameter specifies the storage quota for this site collection in megabytes. These values must not exceed the company’s available quota.

Also, it’s very important to properly designate the correct site Template value/name in this step. We ran into some issues when deleting sites and re-provisioning, even after following the full deletion process which will be described in more detail below.

Step 3 – Add the Site Collection Admin

Add the desired O365 user as a site collection admin to all the appropriate, newly created sites so the user will be able to access the sites and upload content, etc. Add the example code into a PowerShell file and run it from SharePoint Online Management Shell after first making the following changes:

  • Insert the SharePoint Online Global Administrator username on the first line where it shows {insert SharePoint Online Global Admin username here}.
  • Insert the O365 site collection admin’s username on the second line where it shows {insert Site Collection Admin O365 user name here}.
  • Replace the {tenant name} in each Url within the script before running against your tenant.
$admin = '{insert SharePoint Online Global Admin username here}'  
$siteCollectionAdmin = '{insert Site Collection Admin O365 user name here}' 
  
Connect-SPOService -Url https://{tenant name}-admin.sharepoint.com -credential $admin 

Set-SPOUser -Site https://{tenant name}.sharepoint.com/sites/latam -LoginName $siteCollectionAdmin -IsSiteCollectionAdmin $true 
Set-SPOUser -Site https://{tenant name}.sharepoint.com/sites/io -LoginName $siteCollectionAdmin -IsSiteCollectionAdmin $true

Add a line that calls the Set-SPOUser cmdlet for each site where a site collection administrator should be added.

Deleting Site Collections

If a site collection needs to be deleted, it is really a 2-step process:

  • Delete Step 1 — soft “deletes” the current sites by moving them to the Recycle Bin
  • Delete Step 2 — truly deletes these sites by deleting them from the Recycle Bin

Add each Step example below into a separate PowerShell file and run each one from SharePoint Online Management Shell, in order, after first making the following changes:

  • Insert the SharePoint Online Global Administrator username on the first line where it shows {insert SharePoint Online Global Admin username here}.
  • Replace the {tenant name} in each Url within the script before running against your tenant.

Again, be sure to run the Step 1 script first, followed by the Step 2 script later.

Deletion Step 1

 
$admin = '{insert SharePoint Online Global Admin username here}' 
Connect-SPOService -Url https://{tenant name}-admin.sharepoint.com -credential $admin  
  
Remove-SPOSite -Identity https://{tenant name}.sharepoint.com/sites/latam -NoWait 
Remove-SPOSite -Identity https://{tenant name}.sharepoint.com/sites/io -NoWait 

Deletion Step 2

 
$admin = '{insert SharePoint Online Global Admin username here}' 
Connect-SPOService -Url https://{tenant name}-admin.sharepoint.com -credential $admin  
  
Remove-SPODeletedSite -Identity https://{tenant name}.sharepoint.com/sites/latam 
Remove-SPODeletedSite -Identity https://{tenant name}.sharepoint.com/sites/io  

After the site collections are fully deleted, the original steps from the first part of this article can be followed to recreate a site. However, we did run into issues on a recent project when trying to re-provision a site collection with a different template and the same URL, even after fully deleting the original site collection (completed both Step 1 and Step 2 Deletion scripts).  A Microsoft support case was opened by the customer to get the issues resolved since some sites were stuck in an “updating” state or status. This was most likely a rare issue, but it is highly recommended to plan out the site provisioning carefully to avoid the need to delete any sites using this 2-Step Deletion Process.

Kristi WebbProvisioning Modern SharePoint Site Collections

Join the conversation

This site uses Akismet to reduce spam. Learn how your comment data is processed.