Site Settings Export
This PnP PowerShell script captures a comprehensive snapshot of a SharePoint Online site's configuration and exports it to a structured JSON file. It covers everything from basic site properties and installed apps to navigation, permissions, and content types — giving you a complete picture of how a site is set up at a point in time.
Purpose
Exporting site settings is useful when you need to:
- Document a site's configuration before making significant changes
- Compare settings between two environments, such as development and production
- Audit site features, permissions, and installed apps across your tenant
- Recreate or replicate a site configuration on another site or tenant
- Capture a baseline for governance or compliance purposes
What the script exports
The output JSON file includes:
- Basic site information — title, URL, language, web template, and dates
- Site and web-scoped features
- Search settings and crawl status
- Content types available at site level
- Site Pages library settings and enabled content types
- Regional settings including locale and time zone
- Installed apps from the app catalog
- Quick Launch and Top Navigation Bar nodes
- Property bag values
- Site permission groups
- Visible lists and libraries with key settings
- Hub site association details
- Applied site designs
- Indexing status
Prerequisites
- PnP PowerShell module installed
- Site collection administrator permissions
- Access to your PnP app Client Id
PowerShell Script
# SharePoint Site Configuration Comparison Script
param(
[Parameter(Mandatory=$false)]
[string]$SiteUrl = "https://tenantName.sharepoint.com/sites/siteName",
[Parameter(Mandatory=$false)]
[string]$OutputPath = "",
[Parameter(Mandatory=$false)]
[string]$ClientId = ""
)
Write-Host "Connecting to $SiteUrl..." -ForegroundColor Cyan
Connect-PnPOnline -Url $SiteUrl -ClientId $ClientId -Interactive
$siteName = $SiteUrl.Split('/')[-1]
if ($siteName -eq "") {
$siteName = $SiteUrl.Split('/')[-2]
}
$timestamp = Get-Date -Format "yyyyMMdd_HHmmss"
$reportFile = Join-Path $OutputPath "$siteName`_config.json"
Write-Host "Gathering site configuration..." -ForegroundColor Cyan
$config = @{}
# 1. Basic Site Information
Write-Host " - Basic site information" -ForegroundColor Gray
$web = Get-PnPWeb -Includes Title, Url, Language, WebTemplate, Configuration, Created, LastItemModifiedDate
$config.BasicInfo = @{
Title = $web.Title
Url = $web.Url
Language = $web.Language
WebTemplate = $web.WebTemplate
Configuration = $web.Configuration
Created = $web.Created
LastModified = $web.LastItemModifiedDate
}
# 2. Site Features
Write-Host " - Site and web features" -ForegroundColor Gray
$config.SiteFeatures = Get-PnPFeature -Scope Site | Select-Object DisplayName, DefinitionId | Sort-Object DisplayName
$config.WebFeatures = Get-PnPFeature -Scope Web | Select-Object DisplayName, DefinitionId | Sort-Object DisplayName
# 3. Search Settings
Write-Host " - Search settings" -ForegroundColor Gray
try {
$searchSettings = Get-PnPProperty -ClientObject $web -Property AllProperties
$config.SearchSettings = @{
NoCrawl = $searchSettings.NoCrawl
SearchBoxInNavBar = $web.AllProperties["SearchBoxInNavBar"]
SearchScope = $web.AllProperties["SearchScope"]
}
} catch {
$config.SearchSettings = "Error retrieving: $_"
}
# 4. Content Types (Site level)
Write-Host " - Content types" -ForegroundColor Gray
$config.ContentTypes = Get-PnPContentType | Select-Object Name, Id, Group, Hidden | Sort-Object Name
# 5. Site Pages Library Settings
Write-Host " - Site Pages library" -ForegroundColor Gray
try {
$sitePagesLib = Get-PnPList -Identity "Site Pages" -Includes EnableModeration, EnableVersioning, MajorVersionLimit, EnableMinorVersions, RootFolder, NoCrawl, Hidden
$config.SitePagesLibrary = @{
Title = $sitePagesLib.Title
EnableModeration = $sitePagesLib.EnableModeration
EnableVersioning = $sitePagesLib.EnableVersioning
MajorVersionLimit = $sitePagesLib.MajorVersionLimit
EnableMinorVersions = $sitePagesLib.EnableMinorVersions
NoCrawl = $sitePagesLib.NoCrawl
Hidden = $sitePagesLib.Hidden
ItemCount = $sitePagesLib.ItemCount
ContentTypesEnabled = $sitePagesLib.ContentTypesEnabled
}
# Get content types enabled on Site Pages
$sitePagesContentTypes = Get-PnPContentType -List "Site Pages" | Select-Object Name, Id
$config.SitePagesContentTypes = $sitePagesContentTypes
} catch {
$config.SitePagesLibrary = "Error retrieving: $_"
}
# 6. Regional Settings
Write-Host " - Regional settings" -ForegroundColor Gray
$regionalSettings = Get-PnPProperty -ClientObject $web -Property RegionalSettings
$config.RegionalSettings = @{
LocaleId = $regionalSettings.LocaleId
TimeZone = $regionalSettings.TimeZone.Description
}
# 7. Site Collection App Catalog
Write-Host " - App catalog and apps" -ForegroundColor Gray
try {
$apps = Get-PnPApp
$config.InstalledApps = $apps | Select-Object Title, Id, Deployed, AppCatalogVersion | Sort-Object Title
} catch {
$config.InstalledApps = "Error retrieving apps"
}
# 8. Navigation
Write-Host " - Navigation settings" -ForegroundColor Gray
$config.Navigation = @{
QuickLaunch = Get-PnPNavigationNode -Location QuickLaunch | Select-Object Title, Url, Id
TopNavigationBar = Get-PnPNavigationNode -Location TopNavigationBar | Select-Object Title, Url, Id
}
# 9. Property Bag (Custom properties)
Write-Host " - Property bag values" -ForegroundColor Gray
$propertyBag = Get-PnPPropertyBag
$config.PropertyBag = $propertyBag
# 10. Search Schema (Managed Properties relevant to pages)
Write-Host " - Search schema (managed properties)" -ForegroundColor Gray
try {
# This requires search admin permissions
$config.SearchSchema = "Requires Search Admin - run separately"
} catch {
$config.SearchSchema = "Not accessible"
}
# 11. Site Permissions
Write-Host " - Site permissions" -ForegroundColor Gray
$config.SiteGroups = Get-PnPGroup | Select-Object Title, Id, LoginName | Sort-Object Title
# 12. Lists and Libraries Summary
Write-Host " - Lists and libraries" -ForegroundColor Gray
$lists = Get-PnPList -Includes Title, ItemCount, BaseTemplate, Hidden, NoCrawl, EnableModeration
$config.ListsAndLibraries = $lists | Where-Object { -not $_.Hidden } | Select-Object Title, ItemCount, BaseTemplate, NoCrawl, EnableModeration | Sort-Object Title
# 13. Hub Site Association
Write-Host " - Hub site info" -ForegroundColor Gray
try {
$hubSite = Get-PnPHubSite -Identity $SiteUrl -ErrorAction SilentlyContinue
if ($hubSite) {
$config.HubSite = @{
Title = $hubSite.Title
Id = $hubSite.Id
SiteUrl = $hubSite.SiteUrl
}
} else {
$config.HubSite = "Not a hub site or not associated"
}
} catch {
$config.HubSite = "Not a hub site or not associated"
}
# 14. Site Scripts and Site Designs Applied
Write-Host " - Site designs" -ForegroundColor Gray
try {
$siteDesigns = Get-PnPSiteDesign
$config.SiteDesigns = $siteDesigns | Select-Object Title, Id
} catch {
$config.SiteDesigns = "Not accessible"
}
# 15. Indexing Status
Write-Host " - Indexing status" -ForegroundColor Gray
$config.IndexingStatus = @{
NoCrawl = $web.NoCrawl
RequestReindex = "Check site settings manually"
}
# Export to JSON
Write-Host "nExporting configuration to $reportFile..." -ForegroundColor Cyan
$config | ConvertTo-Json -Depth 10 | Out-File -FilePath $reportFile -Encoding UTF8
Write-Host "Configuration exported successfully!" -ForegroundColor Green
Write-Host "File location: $reportFile" -ForegroundColor Yellow
# Disconnect
Disconnect-PnPOnline
Write-Host "nTo compare two sites, run this script against both sites, then use the comparison script." -ForegroundColor Cyan
Usage Notes
- Update the
$SiteUrland$ClientIdparameters before running - Set
$OutputPathto the folder where you want the JSON file saved; leave blank to use the current directory - Retrieving search schema requires Search Administrator permissions and is noted in the output as a manual step
- Run against both a source and target site to generate two config files, then compare them to identify differences
- Test in a non-production environment before using against critical sites