Error when using Get-PnPProvisioningTemplate. Getting error: File Not Found
-
18-02-2021 - |
Вопрос
I want to copy one site to another clean site. I did it a few times weeks ago and it works good. Now I get an error: File Not Found during export template to pnp file. Any idea why?
Connect-PnPOnline -PnPManagementShell -Url https://XXX.sharepoint.com/sites/MDMS
Get-PnPProvisioningTemplate -Out prototype.pnp -IncludeAllClientSidePages
Connect-PnPOnline -PnPManagementShell -Url https://XXX.sharepoint.com/sites/PolishFuncApp
Apply-PnPProvisioningTemplate .\prototype.pnp -ClearNavigation
Решение
Другие советы
Extracts a provisioning template in PNP format from the current web and all client side pages (if set) from the site collection.
Get-PnPProvisioningTemplate -Out template.pnp -IncludeAllClientSidePages
It may be because the prototype.pnp template file does not exist in the scope of the website you specified. Please click the Get-PnPProvisioningTemplate link for more information
You could refer to the following pnp powershell:
try{
$srcUrl = Read-Host "Enter the source site url"
$destUrl = Read-Host "Enter the destination site url"
$pageName = Read-Host "Enter the page name which you want to copy"
Connect-PnPOnline -Url $srcUrl -UseWebLogin
$tempFile = [System.IO.Path]::GetTempFileName();
Export-PnPClientSidePage -Force -Identity $pageName -Out $tempFile
Connect-PnPOnline -Url $destUrl -UseWebLogin
Apply-PnPProvisioningTemplate -Path $tempFile
Write-Host "ModernPage is successfully copied."
sleep 10
}
catch{
Write-Host -ForegroundColor Red 'Error ',':'$Error[0].ToString();
sleep 10
}
You could refer to the following article to get more information:
…………………………………………………Updated Answer……………………………………………
Please follow the steps below to achieve the Copy a Site Collection in SharePoint Online:
Step 1: Connect to the Source site and Get its Schema
#Set variables
$SiteURL = "https://test.spo.com/sites/projects "
$SchmaXMLPath = "C:\Temp\SiteSchema.xml"
#Connect to PnP Online
Connect-PnPOnline -Url $siteUrl -UseWebLogin
#Get Site Schema
Get-PnPProvisioningTemplate -Out ($SchmaXMLPath) -PersistBrandingFiles -PersistPublishingFiles
Step 2: Create a New Site Collection or Subsite
Note:If you have clean site collection, you can skip this step
#Set variables
$SiteURL = "https://test.spo.com/"
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -UseWebLogin
#Create a new subsite
$NewWeb = New-PnpWeb -Title "New Project" -Url "sites/new" -Description "Team Site for Morocco Project" -Locale 1033 -Template "STS#3"
Step 3: Apply the Site Schema into Target Site with Apply-PnP ProvisioningTemplate
#Set variables
$SiteURL = "https://test.sharepoint.com/sites/new"
$SchmaXMLPath = "C:\Temp\SiteSchema.xml"
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -UseWebLogin
#Apply Pnp Provisioning Template
Apply-PnPProvisioningTemplate -Path $SchmaXMLPath -ClearNavigation
You could refer to this article:How to Copy a Site in SharePoint Online using PowerShell.
………………………………………………Updated Answer
…………………………………………
Please try to use the following pnp powershell:
#Connect to the Source site
$SiteURL= "https://test.spo.com/sites/echo"
Connect-PnPOnline -Url $SiteURL -UseWebLogin
#Export the template
Get-PnPProvisioningTemplate -Out “D:\Test.xml”
#Create new site if your site is not created already
New-PnPSite -Type CommunicationSite -Title 'TESTCommun' -URL https://test.spo.com/sites/echo22
#Or
#New-PnPSite -Type TeamSite -Title 'TESTTeam' -Alias 'Testsite' -IsPublic -URL https://test.spo.com/sites/echo22
#Connect to new site
Connect-PnPOnline -Url https://test.spo.com/sites/echo22 -UseWebLogin
#Import the template
Apply-PnPProvisioningTemplate -Path “D:\Test.xml”
You coulde refer to this article Sharepoint PNP: How to copy/clone a SharePoint online site.