Applying site template returns "error applying default columns values"

Brass Contributor

Good morning,

 

When I try to use Invoke-PnPSiteTemplate on a site in my tenant A, by applying the following code:

 

 

#Parameters
$DestinationSiteURL = "https://contoso.sharepoint.com/sites/Master"
$XMLTemplatePath = "D:\Template.xml"

#Connect to PnP Online
Connect-PnPOnline -Url $DestinationSiteURL -Interactive

#Generate import error log
Set-PnPTraceLog -On -LogFile "D:\log.txt" -Level debug

#Apply SharePoint template
Invoke-PnPSiteTemplate -Path $XMLTemplatePath

#Disconnect source SharePoint
Disconnect-PnPOnline

 

 

I get the following error:

 

 

Invoke-PnPSiteTemplate : Error applying default column values
No D:\ImportTemplateSPO.ps1:12 
character:1
+ Invoke-PnPSiteTemplate -Path $XMLTemplatePath
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Invoke-PnPSiteTemplate], PSInvalidOperationException
    + FullyQualifiedErrorId : InvalidOperation,PnP.PowerShell.Commands.Provisioning.Site.InvokeSiteTemplate

 

 

It's a strange behavior because the code was working a few weeks ago, and applying the same template to a website in a different tenant B (where I have even less administrative roles) actually works.

The log also returns this error, which appears after creating views for every list instance in the site:

 

 

PowerShell_ISE.exe Error: 0 : 2023-02-28 10:42:40.5704	[PnP.Framework]	[0]	[Error]	ExecuteQuery threw following exception: Microsoft.SharePoint.Client.ServerUnauthorizedAccessException: Attempted to perform an unauthorized operation.
   em Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream)
   em Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()
   em Microsoft.SharePoint.Client.ClientRequest.<ExecuteQueryToServerAsync>d__53.MoveNext()
--- Fim do rastreamento de pilha do local anterior onde a exceção foi gerada ---
   em System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   em System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   em Microsoft.SharePoint.Client.ClientRequest.<ExecuteQueryAsync>d__39.MoveNext()
--- Fim do rastreamento de pilha do local anterior onde a exceção foi gerada ---
   em System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   em System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   em Microsoft.SharePoint.Client.ClientRuntimeContext.<ExecuteQueryAsync>d__65.MoveNext()
--- Fim do rastreamento de pilha do local anterior onde a exceção foi gerada ---
   em System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   em System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   em Microsoft.SharePoint.Client.ClientContext.<ExecuteQueryAsync>d__28.MoveNext()
--- Fim do rastreamento de pilha do local anterior onde a exceção foi gerada ---
   em System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   em System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   em Microsoft.SharePoint.Client.ClientContextExtensions.<ExecuteQueryImplementation>d__6.MoveNext()
ServerErrorCode: -2147024891
ServerErrorTypeName: System.UnauthorizedAccessException
ServerErrorTraceCorrelationId: fea69aa0-6048-3000-5508-33047c9dde93
ServerErrorValue: 
ServerErrorDetails: 
.	0ms	
PowerShell_ISE.exe Information: 0 : 2023-02-28 10:42:40.5704	[List instances]	[12]	[Debug]	Code execution scope ended	99142ms	b033ca82-1e86-4a2a-ac92-7cba784df7bc
PowerShell_ISE.exe Information: 0 : 2023-02-28 10:42:40.5704	[ProvisioningTemplate WebHook Call]	[12]	[Debug]	Code execution scope started	0ms	b033ca82-1e86-4a2a-ac92-7cba784df7bc
PowerShell_ISE.exe Information: 0 : 2023-02-28 10:42:40.5704	[ProvisioningTemplate WebHook Call]	[12]	[Debug]	Code execution scope ended	0ms	b033ca82-1e86-4a2a-ac92-7cba784df7bc
PowerShell_ISE.exe Information: 0 : 2023-02-28 10:42:40.5704	[Provisioning]	[12]	[Debug]	Code execution scope ended	268555ms	b033ca82-1e86-4a2a-ac92-7cba784df7bc

 


Which makes me believe it is an authorization problem. However, in this tenant A, I have every possible administrative role, including Global Admin.

Which setting that differs from tenant A to B could be causing an error, or is this unrelated to any specific settings? Is there a workaround for this error?

Thanks in advance.

0 Replies