Forum Discussion

Joseph8888's avatar
Joseph8888
Copper Contributor
Jan 15, 2020

Can we create mulitple sites using pnp template

Hello Everyone,

I am able to find below script which will create bunch of site collections from CSV , however I am not able to acheive on how to apply PNP template for all these sites. We want to have same webparts, lists and libraries across all the site using pre-created .xml template using PNP.

try {
Set-ExecutionPolicy Bypass -Scope Process

#Prompt for Tenant url
$TenantUrl = Read-Host -Prompt 'Enter your SharePoint online tenant url'
Connect-pnpOnline -url $TenantUrl

$siteCollectionList = Import-Csv -Path "C:\temp\SiteCollections.csv"

#Loop through csv and provision site collection from each csv entry
foreach ($siteCollection in $siteCollectionList)
{
$SharePointUrl = $siteCollection.Url
$SiteOwner = $siteCollection.Owner
$Title = $siteCollection.Title
$Template = $siteCollection.SiteTemplate
$TimeZone = $siteCollection.TimeZone

#Create site collection based on values above
New-PnPTenantSite -Owner $SiteOwner -Title $Title -Url $SharePointUrl -Template $Template -TimeZone $TimeZone
}

}
catch {
Write-Host $error[0].Message
}
I would like to apply PNPprovosioning template for these sites.
Apply-PnPProvisioningTemplate -Path C:\kumar\PowerShell\template.xml -clearnavigation
How can I incorporate this to above script and loop it for all the sites?
No RepliesBe the first to reply

Resources