Invoke-SSPSiteTemplate.ps1
<# .Synopsis Instantiates a new site from the given template. .Description This CmdLet gets a SiteTemplate from a source and instantiates it at the destination url. .Parameter FileName This parameter contains the path of the template file. .Parameter Dest This parameter contains the Url of the destination site. .Parameter DestConnection This parameter contains the connection context for the destination site. The default is the current connection returned by "Get-PnPConnection". .Parameter Handlers This parameter contains a list of the handlers to invoke for the template. Default is ALL. .Parameter Runs This parameter contains a number of runs to use in applying the template to the site. It is found that probably due to temporal issues for Sharepoint, that multiple runs are necessary. Default is 2. #> function Invoke-SSPSiteTemplate { param( [parameter(Mandatory=$true)] $fileName, [parameter(Mandatory=$true)] $destConnection, [parameter(Mandatory=$false)] $runs = 2, [parameter(Mandatory=$false)] $handlers = "ALL" ) $n = $runs while($n -gt 0) { try { Invoke-PnPSiteTemplate -Path $fileName -Handlers $handlers -Connection $destConnection -ClearNavigation -IgnoreDuplicateDataRowErrors $n -= 1 } catch { Write-Error $PSItem.ToString() $n -= 1 } } } |