Import Multiple Pages
This PnP PowerShell script automates the import of multiple SharePoint pages from backup files, migration packages, or content archives. Restore page content, metadata, and configurations in bulk operations.
Purpose
This script helps you:
- Restore multiple SharePoint pages from backup files
- Import pages during site migration or content restoration
- Bulk create pages from standardized templates
- Deploy page content across multiple sites or environments
Prerequisites
- PnP PowerShell module installed
- Site collection administrator permissions
- Connection to your SharePoint Online site
- Exported page files or content packages
- Appropriate content types and page layouts configured
PowerShell Script
# Script will be added here
# Connect to SharePoint Online site
# Connect-PnPOnline -Url "https://yourtenant.sharepoint.com/sites/yoursite" -Interactive
# Your PnP PowerShell script for importing multiple pages will go here
JSON Configuration File
{
"importSettings": {
"sourcePath": "C:\\PageImports\\",
"targetLibrary": "Site Pages",
"overwriteExisting": false,
"preserveMetadata": true,
"importWebParts": true
},
"pagesToImport": [
{
"sourceFile": "homepage-export.json",
"targetPageName": "Home.aspx",
"contentType": "Site Page",
"publishAfterImport": true,
"customProperties": {
"Title": "Home Page",
"Description": "Main landing page"
}
},
{
"sourceFile": "about-export.json",
"targetPageName": "About.aspx",
"contentType": "Site Page",
"publishAfterImport": true,
"customProperties": {
"Title": "About Us",
"Description": "Company information page"
}
},
{
"sourceFile": "services-export.json",
"targetPageName": "Services.aspx",
"contentType": "Site Page",
"publishAfterImport": false,
"customProperties": {
"Title": "Our Services",
"Description": "Service offerings page"
}
}
],
"mappingRules": {
"webPartMappings": {
"OldWebPartType": "NewWebPartType"
},
"urlReplacements": {
"https://olddomain.sharepoint.com": "https://newdomain.sharepoint.com"
}
}
}
Usage Notes
- Ensure target site has necessary content types and page layouts
- Review URL mappings and web part compatibility before import
- Test import process with a single page before bulk operations
- Consider page dependencies and navigation structure updates
- Backup target site before performing bulk page imports