Forum Discussion
Home.aspx content and webparts when extracting PnP site provisioning schema?
- Jan 14, 2017
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).
Hi Deleted
Great blog post! Thank you for sharing it. Your post will certainly help after my initial problem has been resolved.
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?
- Pasi BergmanNov 01, 2016Copper Contributor
Thanks again for contributing. This issue is quite annoying and any help is appreciated.
As I mentioned, the extracted provisioning template (xml) does not contain Pages element nor Page element. Below is the result of the initial schema extraction
Get-SPOProvisioningTemplate -Out .\mytemplatesite1.xml
I have removed the content of the AdditionalAdministrators, SiteFields and ContentTypes, but I have not touched anything else.
<?xml version="1.0"?> <pnp: Provisioning xmlns: pnp="http://schemas.dev.office.com/PnP/2016/05/ProvisioningSchema"> <pnp: Preferences Generator="OfficeDevPnP.Core, Version=2.8.1610.1, Culture=neutral, PublicKeyToken=3751622786b357c2" /> <pnp: Templates ID="CONTAINER-TEMPLATE-2912D0BE8A6047548043990D05268BC2"> <pnp: ProvisioningTemplate ID="TEMPLATE-2912D0BE8A6047548043990D05268BC2" Version="1" BaseSiteTemplate="STS#0"> <pnp: WebSettings RequestAccessEmail="someone@example.com" NoCrawl="false" WelcomePage="SitePages/Home.aspx" SiteLogo="" AlternateCSS="" MasterPageUrl="{masterpagecatalog}/seattle.master" CustomMasterPageUrl="{masterpagecatalog}/seattle.master" /> <pnp: RegionalSettings AdjustHijriDays="0" AlternateCalendarType="None" CalendarType="Gregorian" Collation="25" FirstDayOfWeek="Sunday" FirstWeekOfYear="0" LocaleId="1033" ShowWeeks="false" Time24="false" TimeZone="13" WorkDayEndHour="5:00PM" WorkDays="62" WorkDayStartHour="8:00AM" /> <pnp: SupportedUILanguages> <pnp: SupportedUILanguage LCID="1033" /> </pnp: SupportedUILanguages> <pnp: AuditSettings AuditLogTrimmingRetention="90" TrimAuditLog="true"> <pnp: Audit AuditFlag="None" /> </pnp: AuditSettings> <pnp: Security> <pnp: AdditionalAdministrators> </pnp: AdditionalAdministrators> <pnp: Permissions /> </pnp: Security> <pnp: SiteFields> </pnp: SiteFields> <pnp: ContentTypes> </pnp: ContentTypes> <pnp: Features> <pnp: WebFeatures> <pnp: Feature ID="b77b6484-364e-4356-8c72-1bb55b81c6b3" /> </pnp: WebFeatures> </pnp: Features> </pnp: ProvisioningTemplate> </pnp: Templates> </pnp: Provisioning>
Edit: I added spaces after each pnp: to remove the emojis from my reply.
- Nov 01, 2016
Hi Pasi Bergman,
I just tried creation a new site collection using the team site template. Then I exported it and I'm getting a lot more back.
for examples my sitefields look like this:
< pnp: SiteFields>
<Field ID="{e954460e-4ac3-463a-a9c4-bf9e55564e24}" Type="DateTime" DisplayName="Last Shared By Time" Name="LastSharedByTime" StaticName="LastSharedByTime" Group="_Hidden" Sealed="TRUE" AllowDeletion="FALSE" ReadOnly="TRUE" ShowInDisplayForm="FALSE" ShowInEditForm="FALSE" ShowInListSettings="FALSE" Viewable="FALSE" SourceID="{808997ce-c646-44e1-aa26-8b96b3fa034c}" />
<Field ID="{ef991a83-108d-4407-8ee5-ccc0c3d836b9}" Type="UserMulti" DisplayName="Shared With" Mult="TRUE" Name="SharedWithUsers" StaticName="SharedWithUsers" Group="_Hidden" Sealed="TRUE" AllowDeletion="FALSE" ReadOnly="TRUE" ShowInDisplayForm="FALSE" ShowInEditForm="FALSE" ShowInListSettings="FALSE" Viewable="FALSE" SourceID="{808997ce-c646-44e1-aa26-8b96b3fa034c}" />
<Field ID="{725e8dc4-ee43-488a-94fa-85a380aa1302}" Type="Note" DisplayName="Last Shared By User" Name="LastSharedByUser" StaticName="LastSharedByUser" Group="_Hidden" Sealed="TRUE" AllowDeletion="FALSE" ReadOnly="TRUE" ShowInDisplayForm="FALSE" ShowInEditForm="FALSE" ShowInListSettings="FALSE" Viewable="FALSE" SourceID="{808997ce-c646-44e1-aa26-8b96b3fa034c}" />
<Field ID="{d3c9caf7-044c-4c71-ae64-092981e54b33}" Type="Note" DisplayName="Shared With Details" Name="SharedWithDetails" StaticName="SharedWithDetails" Group="_Hidden" Sealed="TRUE" AllowDeletion="FALSE" ReadOnly="TRUE" ShowInDisplayForm="FALSE" ShowInEditForm="FALSE" ShowInListSettings="FALSE" Viewable="FALSE" SourceID="{808997ce-c646-44e1-aa26-8b96b3fa034c}" />
</ pnp: SiteFields>It almost looks like you haven't got the rigth permissions or something else is going wrong.
I looked at your connect-sponline command:
Connect-SPOnline -Url https://mytenant.sharepoint.com/sites/mytemplatesite -UseWebLogin
Can you try without the -UseWebLogin
and use something like this:
$url = "https://mytenant.sharepoint.com/sites/testteam" $username = "admin@mytenant.onmicrosoft.com" if ($credentials -eq $null) { $credentials = Get-Credential -Message "Please supply password" -UserName $username Connect-SPOnline $url -Credentials $credentials }
- Pasi BergmanNov 01, 2016Copper Contributor
Great suggestion. This issue is somehow related to the login method.
I execute the following PowerShell lines. Note! The SharePointPnPPowerShellOnline\ is there because of same names of the diefferent SharePointPnPPowerShell* modules have same cmdlet's with the same name ('clobber').
$site = "https://mytenant.sharepoint.com/sites/pasi-test-template" SharePointPnPPowerShellOnline\Set-SPOTraceLog -On -Level Debug -LogFile .\mytemplate-creds.log
# # Log in using network credentials - requires <tenant>.onmicrosoft.com account
#
$Creds = Get-Credential SharePointPnPPowerShellOnline\Connect-SPOnline -Url $site -Credential $Creds SharePointPnPPowerShellOnline\Get-SPOProvisioningTemplate -Force -Out .\mytemplate-creds.xml SharePointPnPPowerShellOnline\Set-SPOTraceLog -Off SharePointPnPPowerShellOnline\Set-SPOTraceLog -On -Level Debug -LogFile .\mytemplate-weblogin.log #
# Log in using Web Login - you can use any valid accout
# SharePointPnPPowerShellOnline\Connect-SPOnline -Url $site -UseWebLogin SharePointPnPPowerShellOnline\Get-SPOProvisioningTemplate -Force -Out .\mytemplate-weblogin.xml SharePointPnPPowerShellOnline\Set-SPOTraceLog -OffThe result:
- Using the -Credential produces the xml WITH the page content.
- Using the -UseWebLogin produces the xml WITHOUT the page content.
I'm using only one and same credential in both cases. Result XML file is different.
I'm attaching the trace logs of both runs. The logs show that in -Credential case the Pages is handled (don't worry about the webpart warnings). In -UseWebLogin the Pages is not handled.