PnPPowerShell

In this post I will describe some simple steps on how to provision a new site collection and apply a template on it with the PnP PowerShell CmdLets. Before using these PnP PowerShell CmdLets, I installed the binaries for these CmdLets which can be found here.

Step 1: Connect to your SharePoint Online environment with the CmdLet Connect-SPOnline:

Connect-SPOnline -Url “https://<tenant>-admin.sharepoint.com/”
(This command will prompt for credentials, use an account with tenant admin rights / SharePoint role)

Step 2: Create a site collection via the PowerShell CmdLet New-SPOTenantSite

New-SPOTenantSite (https://github.com/OfficeDev/PnP-PowerShell/blob/master/Documentation/NewSPOTenantSite.md)

New-SPOTenantSite -Title “Template Site Collection”-Url “https://<tenant>.sharepoint.com/sites/template” -Owner “” -Lcid 1033 -Template “STS#0” -TimeZone 2 -StorageQuota 1000 -RemoveDeletedSite
(When this command is executed it process the creation of a new site collection)

Step 3: Make some changes to the newly created site

– change the look
– add content type
– add a document library

Step 4: Export the site collection to an xml template file

Get-SPOProvisioningTemplate (https://github.com/OfficeDev/PnP-PowerShell/blob/master/Documentation/GetSPOProvisioningTemplate.md)

If PowerShell is still open after the site is created (step 2) then execute command Disconnect-SPOnline. Then execute the command Connect-SPOnline -Url “https://<tenant>.sharepoint.com/sites/template”

Get-SPOProvisioningTemplate Out template.xml

Step 5: Now, again create a new site collection as shown in step 2

Step 6: Connect again to the newly created site collection

Connect-SPOnline

Step 7: Apply the provisioning template to the new site collection


Apply-SPOProvisioningTemplate -Path template.xml

Step 8: Check the site collection and you will see the changes made in the template site collection now in your newly created site collection.

 

Resources:

 

Neem contact op

Coltbaan 4E
3439 NG Nieuwegein

+31 (0)85 - 489 1008

Meer informatie?

%d bloggers like this: