2 • • • • During my last project we were asked to create a fairly simple site template on Office 365. I typically cringe when I hear the word site definition / site template or web template. The reason goes way back to the beginning of my career with SharePoint. One of my first projects I had to upgrade a site definition from 2007 to 2010. I’m not going to complain too much but let’s just say that there was barely any documentation on how to accomplish this. For a n00b I struggled through it and I guess I completely it successfully. Just query SPWeb.WebTemplateId. SharePoint 2010 - find template used create site: In SharePoint 2010, You can get the list of site templates by using a PowerShell Cmd-let: Get-SPWebTemplate. Examples for listing Web Templates: Get-SPWebTemplate -Identity SGS#0. Get-SPWebTemplate -Identity S*. The MSDN documentation of the Createweb STSADM operation suggests that it cannot use site templates that are uploaded to the site's site template gallery: Specifies the type of template to be used by the newly created site. If you do not specify a template to use, the owner can choose a template when he. More Stsadm Createsite Site Template images. Stsadm -o createsite -url. Specifies the type of template to be used by the newly created site. If you do not specify a template to use. Fast forward to today the last time I created a web template for Office 365 I was able to build the site and then “Save as Template”. This worked because it was not a publishing site, but a team site. ![]() ![]() That template saved successfully by it created some monstrous WSP with tons of files, folders, feature and XML definitions. To make any changes to the template I had to scan through those XML definitions. The experience was not fun to say the least. I was researching the deep and dark interwebs on “the best method to create site templates on Office 365”. The result of that research showed that the shift is towards remote site provisioning using either your client machine, a provider hosted add-in or another method like web job, remote timer job, Azure function. Basically anything capable of running remote client object model code to programmatically build out your site. ![]() I chose to perform remote site creation via PnP-Powershell []. The PnP-Powershell team has been doing fantastic work. They currently a couple of ways to do remote site provisioning. • provision from a live site (as a template) • provision from a xml definition – this can be exported from a live site and saved for reuse Unfortunately I wasn’t able to get either of those options to work for me because of a know issue that they are working on. ![]() I decided that I was going to continue to use the PnP-Powershell commands to programmatically create the site instead of using some of their provisioning commandlets. If your just getting started then I suggest checking out these following resources on remote provisioning • • • Getting Started The first thing you’ll need to do is visit the GitHub site for PnP-PowerShell –. You’ll need to make sure that you have the pre-requisites installed. You also need to install the PnP commandlets with the command below. Install - Module SharePointPnPPowerShellOnline - AllowClobber In the following paragraphs I’m going to demonstrate the code that was ultimately used as the solution. My code template required the following items: • Lists • Announcements • Calendar • Web Parts on Home Page • Announcements • Custom Display (using display template) • Calendar • Document Library This should give you a basic idea of what we need to accomplish. The Commands Next up is the current set of commands that I ran to provision the new site. Set -PnPWebPartProperty -ServerRelativePageUrl $homePage -Identity $wp. Id -Key 'ChromeType' -Value 2 Summary In end the I was happy with the results. I found out shortly after speaking with a colleague, aka our provisioning guru, that this could be all nicely packaged up and put into an Azure function. This way that someone doesn’t have to run the code on their desktop. It could be implemented in a cloud way where you just need to trigger that function to run possibly using Flow where you just enter the site creation information into a list and it fires away or a custom form. Bottom line is that I’m excited to really see the potential of the PnP initiatives. It has some glitches with some of the commandlets during the time that I tried it but I can see how it will become very powerful once it fully matures. Yes that is possible. I have a posting coming out soon on that but in the meantime you can check out these commands below. (you can export a template from a site then re-import This is slightly dated (the commands have been renamed) but the idea is the same – [Provisioning Section [Get-PnPProvisioningTemplate [Apply-PnPProvisioningTemplate [There are a few options involved. You can create a site as a template and export templates to disk, azure, and i forget the last one.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
March 2018
Categories |