Using the PnP Framework to Transfer SharePoint Data Efficiently

Using the PnP Framework to Transfer SharePoint Data Efficiently


SharePoint and Power Apps integration offers numerous possibilities, especially when it comes to data management. Moreover, one recurrent need in this domain is the migration of data, lists, and even entire sites between different SharePoint environments. This might be for backup, testing, or even replication purposes. Therefore, we’re going to delve into the steps to utilize PowerShell and the PnP Framework, specifically focusing on the register-pnpmanagementshellaccess keyword, for these migrations.

SharePoint is a frequently used data source with Power Apps. Additionally, its compatibility with Microsoft 365 licenses without additional charges makes it a preferred choice for many app builders. These builders often face a challenge: moving data, lists, or entire sites between various SharePoint sites or even different organizations.

What is the PnP Framework and Provisioning Engine?

The PnP (Patterns and Practices) Framework and Provisioning Engine are designed for this specific task. Furthermore, through these tools, one can define a SharePoint site, encompassing lists, columns, content types, pages, and more, using templates. These templates could be in XML, JSON, or a PnP file format. Subsequently, using PowerShell commands, one can then employ the Provisioning Engine to set up these templates.

For a comprehensive understanding, you can refer to the official Microsoft documentation.

Setting up PnP PowerShell

To initiate the process, we need to install PnP PowerShell. After starting PowerShell as an administrator, we use the following command:

Install-Module -Name PnP.PowerShell

During the installation, you might have to approve the module’s download from an untrusted source. Once installed, run the command to provide access to the PnP Management Shell:


Exporting SharePoint Site Definitions

With the setup complete, you can now export your desired SharePoint site to a local file using the following PowerShell commands:

  Connect-PnPOnline -Url ""
  Get-PnPSiteTemplate -Out "C:\PowerApps\SharePoint\mySite.xml"
  Add-PnPDataRowsToSiteTemplate -Path "C:\PowerApps\SharePoint\mySite.xml" -List "PropertyType"
  Add-PnPDataRowsToSiteTemplate -Path "C:\PowerApps\SharePoint\mySite.xml" -List "Property"

Inspecting the Template

Post-export, you can review the XML template using tools like Visual Studio Code. This will show you the XML defining various lists, data records, and more. For those who are adept, manual modifications can also be made to this XML.

Importing Changes to a Destination SharePoint Site

To implement the changes from your template to a new site, a destination site on the SharePoint server is required. Then, you can connect to this site and install the template using the following commands:

  Connect-PnPOnline -Url ""
  Invoke-PnPSiteTemplate -Path "C:\PowerApps\SharePoint\mySite.xml"


Migrating SharePoint objects between sites or servers can be streamlined with the PnP Framework and Provisioning Engine. Through this guide, we walked you through the essentials of transferring data using PowerShell.

If you face any challenges or need more technical assistance, feel free to contact us, and we’ll be glad to assist you.

About The Author