Create Communication Sites

A PowerShell with SharePoint tutorial

PowerShell iconIn earlier articles, we have been working with SharePoint app creation and removal, but now we will go over to sites. We will start with modern SharePoint communication sites.

In the demo below, Peter Kalmström uses an array with department names that he created from an Excel list in an earlier demo. He wants to give each of the departments a new site collection, and here he writes a forEach loop that creates one root site  for each department.

The URL for each communication site will end with the department name, and Peter also lets the forEach create progress messages during the site generation.

PowerShell created communication sites

Peter uses the cmdlet, New-PnPSite for the site creation and the site type is hardcoded to CommunicationSite.

foreach($Dep in $Departments){
    $SiteURL = "PATH/" + $Dep
    Write-Host ($SiteURL + " is being created ...") -ForegroundColor Yellow
    New-PnPSite -Type CommunicationSite -Title $Dep -Url $SiteURL
}

Peter adds subsites to the HQ site collection in a later article.

PowerShell command pane

In the next demo, Peter shows how to remove all the communication sites again.





back icon next icon
Products Buy FAQ Services Tips Books Contact About Us Tools

Security and integrity

Copyright  Kalmstrom Enterprises AB  All rights reserved