1

I'm trying to export/import modern pages from one site to another. The page contents seem to work great, but no page metadata is copied over. Is there a way to include the content type and fields in the export/import process?

1 Answer 1

1

By default PnP PowerShell does not support it,

You need to create custom extensibility handler for it.

I have created handler for you which you can find it at below link and you can adapt it based on your requirement. Based on Different type of field you need to add value with different format. e.g. In case of User field you need to add UPN, In case of Taxonomy field you need to add format TermLabel | TermID

https://github.com/kavaghela/pnp-ExtensibilityHandler/blob/main/CreateSiteFromTemplate/PnPCustomHandler/Class2.cs

Pnp Template Value Support for different field type

<pnp:FieldValues>
        <pnp:FieldValue Key="TaxonomyField" Value="Sample Term|06ecb235-97b2-4d31-b31c-86f5ab78df13" />
        <pnp:FieldValue Key="NormalField" Value="Sample Project" />
        <pnp:FieldValue Key="DateField" Value="11-11-2020 00:00:00" />
        <pnp:FieldValue Key="UserField" Value="{UPN of User}" />
        <pnp:FieldValue Key="HyperlinkField" Value="{site}/SiteAssets/bsone-SampleNewsEntry/bsonePageImage.jpg,{site}/SiteAssets/bsone-SampleNewsEntry/bsonePageImage.jpg" />
        <pnp:FieldValue Key="bsoneRollupImage" Value="{site}/SiteAssets/bsone-SampleNewsEntry/bsoneRollupImage.jpg,{site}/SiteAssets/bsone-SampleNewsEntry/bsoneRollupImage.jpg" />
      </pnp:FieldValues>

You can find guideline how to add custom handler from official documentation of PnP PowerShell -> https://pnp.github.io/powershell/cmdlets/Get-PnPProvisioningTemplate.html#example-8 (Important: Command name might be changed based on which version of PnP PowerShell you are using)

Hope it will helpful to you.

1
  • This is interesting, thanks! I'll see if I can use your example for my needs. Commented Jul 28, 2022 at 4:43

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.