Forum Discussion
Pasi Bergman
Nov 01, 2016Copper Contributor
Home.aspx content and webparts when extracting PnP site provisioning schema?
Should I be able to get the page content of the site welcome page (e.g. /SitePages/Home.aspx) and its webparts using Get-SPOProvisioningTemplate (PowerShell) or GetProvisioningTemplate (C#)? I would think welcome page content and webpart extraction this is included in the core implementation as that is normally needed when extracting site schema.
How do I extract the SitePages/Home.aspx content with webparts? Do I need to implement an extensibility provider?
A little update from the PnP Core Team: I just changed the behaviour of the PageContents handler (which is the handler that extracts the homepage). It was checking for the presence of Credentials on the ClientContext and if not present it would not execute the extraction of artifacts. That check is still valid for On-Premises, due to the fact that we have to call a webservice to work around CSOM limitations, but is not needed anymore for SPO as that version of CSOM allows us to export all webparts. I now made that check conditional based upon the version of the NuGet package you're running, and it will be available in version 2.12.1702.0 (the February 2017 release).
13 Replies
Sort By
- Anonymous
Be aware that if you put webparts on the homepage which contain documents/lists that the view is not automaticly the same.
check my blog about views:
http://www.sharepoint-specialist.nu/unable-change-view-list-view-web-part-csom-solution-office365/
- Pasi BergmanCopper Contributor
Hi Deleted
Great blog post! Thank you for sharing it. Your post will certainly help after my initial problem has been resolved.
- When you export as .xml files the aspx page itself will not be exported.
You can simple put an .aspx file in the same folder as the .xml manually before you import it. A simple one off export of the page with share point designer will do. You can then use this apsx file for any future pages.
If you use .pnp rather than .xml then all will work fine.
Did you check you .xml files? If you search for webpart do you find anything in the xml?
Hi Pasi Bergman,
The Get-SPOProvisioingTemplate cmdlet collects the welcome page including web parts.
I'm assuming that you are extracting the template as a .pnp file. If you extract it as an .xml it will be easier to check if your page/web parts are included. Of course it is better to use the .pnp format for normal use but for debug purposes it can help to use the .xml format.
- Pasi BergmanCopper Contributor
Thank you for taking the time to reply. I really appreciate it.
I am expecting the Get-SPOProvisioingTemplate to collect also the Home.aspx but the XML file I'm getting does not include Pages element and threfore no page content nor webpart either.
This is what I do...
1) I create a new SharePoint Online Team Site (English) with my account as the site collection administrator
2) I then edit the welcome page /SitePages/Home.aspx. I remove the default content except for the Documents webpart. I also add some text to the wikifield content area and then I save the page.
3) Using the latest PnP SharePoint Online PowerShell I then
Connect-SPOnline -Url https://mytenant.sharepoint.com/sites/mytemplatesite -UseWebLogin Get-SPOProvisioningTemplate -Out .\mytemplatesite1.xml
6) I also try
Get-SPOProvisioningTemplate -Out .\mytemplatesite2.xml -PersistPublishingFiles
and
Get-SPOProvisioningTemplate -Out .\mytemplatesite3.xml -IncludeNativePublishingFiles
None of these prorduce xml file with the Pages element and content of the Home.aspx (i.e. WebPart and WikiField contents).
I won't attach the schema xml's. Hopefully everyone takes my word for it that the Pages there is no Pages nor Page element in those. I'm attaching the TRACE LOGs of the three Get-SPOProvisioningTemplate executions numbered as 1, 2 and 3.