PnP PowerShell - Can we get List content in List template xml?

1.2k Views Asked by At

I am new to the PnP PowerShell. I want to provision list using list template for Document Library. I can get it using below command:

Export-PnPListToProvisioningTemplate -Out C:\DocumentLibraryTemplate.xml -List "Documents"

But Is there any way I can get Content of that library as well in xml. So that I can provision the same on another site ? Thank you in advance.

1

There are 1 best solutions below

1
G Kris On

Maybe you can use the commands below:

Install-Module -Name PnP.PowerShell
Connect-PnPOnline -Url https://constoso.sharepoint.com/sites/star-wars -Interactive
Get-PnPSiteTemplate -Out Lists.xml -ListsToExtract "Middle Earth Locales", "Fellowship Members" -Handlers Lists
Add-PnPDataRowsToSiteTemplate -Path Lists.xml -List "Middle Earth Locales"

Add-PnPDataRowsToSiteTemplate -Path Lists.xml -List "Fellowship Members"
Connect-PnPOnline -Url https://constoso.sharepoint.com/sites/lotr -Interactive

Invoke-PnPSiteTemplate -Path Lists.xml

Reference: https://techcommunity.microsoft.com/t5/microsoft-365-pnp-blog/copy-a-list-with-list-items-to-another-site/ba-p/2248892