Power Community

Power Community

2 ways to duplicate SharePoint Lists to support your Power Apps

Recently I’ve been asked quite a few times to duplicate SharePoint lists as part of creating a Development, Test and production environment in Power Apps.

PnP PowerShell

Whatever you want to do to SharePoint, PnP PowerShell is often the quick way of doing things. Especially if you want to undertake the same thing. One of these common reasons to use PnP PowerShell for me is to create a copy of a SharePoint site to support my 3 environment setup in my Power Platform solutions.

With the power of scripting and automation, you can save time and effort by replicating lists with ease. In this article, I will look at the various strategies to guide you through the process of duplicating lists in SharePoint using PnP PowerShell.

To install or update your PnP PowerShell, simply type the following line in your PowerShell Terminal in Visual Studio Code.

install-module PnP.Powershell -Scope CurrentUser

It had been a while since I last wrote about PnP PowerShell and replicating sites and so much has changed over the last few years,

Strategy 1 – Duplicate SharePoint list (or a small number of lists)

To duplicate a SharePoint list using PnP PowerShell, start by connecting to your SharePoint site using the Connect-PnPOnline cmdlet. Once connected, use the Copy-PnPList cmdlet to copy the list you want to duplicate to a site:

Connect-PnPOnline https://pieterveenstramvp.sharepoint.com/sites/Finance-PnPManagementShell

Copy-PnPList -Identity "Flooded List" -DestinationWebUrl https://pieterveenstraMVP.sharepoint.com/FinanceDevelopment

The above will replicate the list but not the content of the list. Quite often I don’t want to replicate the list content however for lookup lists it might help if the content is replicated as well. But that I can have a look at in a different post.

Duplicate SharePoint Lists using Copy-PnPList

Strategy 2 – Dusplicate a whole site

Quite often I want to not just replicate one list in a site, I want to replicate multiple lists to potentially multiple sites.

Typically, I would use the following script, to read a template form a site and then use the template, to recreate the various elements on my Development and Test copies of the site.

Connect-PnPOnline https://pieterveenstraMVP.sharepoint.com/sites/Finance -PnPManagementShell
Get-PnPSiteTemplate -Out template.xml -ExcludeHandlers SiteSecurity

Connect-PnPOnline https://pieterveenstraMVP.sharepoint.com/sites/FinanceDevelopment -PnPManagementShell
Invoke-PnPSiteTemplate -Path template.xml

Connect-PnPOnline https://pieterveenstraMVP.sharepoint.com/sites/FinanceTest -PnPManagementShell
Invoke-PnPSiteTemplate -Path template.xml

The above I would typically use if, I’m in a situation where a new client has developed all their apps in a single environment and they are looking at moving towards a separation between Development, Test and Production.

This post was originally published on this site

- Advertisement -spot_img


Please enter your comment!
Please enter your name here

- Advertisement - Advertisement

Latest News

5 Benefits of In-App Notifications for Microsoft Dynamics 365 CRM users

For a successful sales process, you need to stay up-to-date with crucial sales information like deal closures, opportunities won,...

More Articles Like This

- Advertisement -spot_img