The PnP Provisioning Framework is a code-centric, model-driven platform for provisioning your web site collections. The brand new provisioning engine permits you to retain and reuse provisioning templates throughout Workplace 365, SharePoint On-line, and on-premises web site collections.
This weblog exhibits tips on how to provision a workforce web site utilizing PnP PowerShell. On this course of, we’ll use an present SharePoint web site to create a reusable template. With this template, we will create precisely comparable websites a number of occasions for a number of purchasers.
Know your stipulations
To run some instructions, you will need to have the PnP PowerShell framework already put in in your pc. If it’s not put in, you may merely set up it by working the next command on the command immediate: Set up Module -Title PnP.PowerShell. Or you may discuss with this hyperlink for extra directions on tips on how to set up PnP PowerShell.
When you’re achieved, begin Home windows PowerShell in “administrator” mode and run the next command to put in the PnP PowerShell module for SharePoint On-line:
SharePointPnPPowerShellOnline set up module
If that is the primary time you have run PnP PowerShell instructions in your system, chances are you’ll have to grant PowerShell entry to your SharePoint on-line web site. To offer entry, run the next command in Home windows PowerShell:
You at the moment are able to run PnP PowerShell instructions in your system.
Course of Overview
The next picture exhibits the essential course of we’ll comply with to provision a web site utilizing the PnP provisioning framework:
- Extraction mannequin
- Customizing artifacts and different settings within the mannequin
- Apply a template to the brand new vacation spot web site
Learn how to extract the positioning template
As already talked about, we will likely be utilizing an present web site to arrange our PnP mannequin. The simplest option to get a customized provisioning mannequin is to manually create a brand new web site assortment in SharePoint On-line, configure its artifacts (web site columns, content material sorts, lists, and pages), and save the consequence as a provisioning mannequin.
As soon as the positioning is configured, we’ll pull the mannequin from this web site utilizing PnP PowerShell.
Observe these steps:
- Open Home windows PowerShell in “Admin” mode
- Connect with the newly created web site by working the next command:
This command will hook up with your web site assortment from PowerShell. You’ll be able to entry all artifacts like lists, libraries, web site property, permissions, web site particulars, and so on. for the presently linked web site utilizing PnP PowerShell instructions.
- You may be prompted for credentials, so enter the login credentials on your web site.
- If you do not get a immediate to enter your credentials, create a credential object and go it to the “Join” command:
$consumer = ” «
$secpasswd = ConvertTo-SecureString « » -AsPlainText -Energy
$mycreds = New System.Administration.Automation.PSCredential object ($consumer, $secpasswd)
Join-PnPOnline -url $siteAdminURL -Credentials $mycreds
- Run the next command to export the positioning template in XML format:
Get-PnPSiteTemplate -Out “D:PnP-TemplateForSite.xml”
On this command, you may specify the trail the place it’s essential to obtain the template and tips on how to identify the template file. On this case, the template will likely be created on drive “D:” with the identify “PnP-TemplateForSite.xml”.
The mannequin is created in your particular path after executing the command. It is going to be an .xml file since we offer the “.xml” extension on a file identify. The mannequin will appear like this:
That is what our PnP mannequin will appear like. This template comprises all the small print in regards to the PnP provisioning scheme model, identify, and so on. It has totally different tags to configure or customise a web site. We will configure web site brand, listings, web site members, web site fields, web site navigations, permissions, and safety for this template.
Parameters for customized configuration extraction
We will resolve which settings we have to embrace within the present web site’s PnP template by including further parameters within the “Get-PnPSiteTemplate” command. We will use totally different parameters within the command. For extra details about the totally different parameters, you may discuss with this hyperlink.
Create a brand new web site or vacation spot web site with PnP PowerShell
As soon as the template is extracted, we will apply this template to any newly created web site. Earlier than creating the template, we’ll create a brand new trendy web site utilizing the next PnP PowerShell command:
New-PnPSite -Kind TeamSite -Title “New Goal Website”
The code will immediate you to set an alias identify after executing the command. You’ll present an alias identify and press “Enter”. Subsequent, you will begin creating the web site within the linked tenant. Please observe that web site creation could take a while. After creating the positioning, the brand new web site URL will seem in Home windows PowerShell, as proven within the following picture:
Software of the PnP mannequin to the brand new vacation spot web site
Earlier than making use of the extracted provisioning mannequin to the newly created goal web site, you will need to be certain that the brand new goal web site is up and working correctly. To do that, we’ll first want to hook up with the brand new goal web site from PnP PowerShell after which apply the template to it. To do that, run the next instructions in Home windows PowerShell:
Invoke-PnPSiteTemplate -Path “D:PnP-TemplateForSite.xml”
The ” -Path “ The argument refers back to the supply template file we created within the earlier steps “PnP-TemplateForSite.xml”. When specifying the file identify, ensure that there aren’t any areas within the file identify.
As soon as the order is executed, you will note the progress of the mannequin provisioning on the positioning as follows.
The template utility can take 20-Half-hour if the template comprises too many customizations. This length could range relying on the complexity of the PnP mannequin that we apply to the positioning. When the command completes, you may see that the vacation spot web site has all of the customization and artifact set we configured within the PnP template utilized.
We will apply the identical template to as many websites as we would like. This course of permits us to automate the creation of a number of equivalent websites with the identical set of lists, libraries, content material sorts, web site fields, permissions, and the like with out going by any further effort to manually configure all of this for every web site.
On this weblog, we discovered tips on how to use PnP PowerShell and PnP Provisioning Template to use a customized template to a newly created web site to automate the creation course of and apply customized configurations and artifacts. To study extra, contact our enterprise specialists right now.