Create Modern Communications site in SharePoint Online using powershell
With the introduction of Modern Sites in SharePoint there are a few ways you can create Modern sites including via the GUI screen, however what do you do if the creation of sites has been locked down to only allow administrators?
In situations like that we can revert to using PowerShell to create our Modern Sites, we could even use this to mass create s number of sites at once. In this scenario we will look at creating a Communication Site which has a slight difference in the syntax to that of creating a Modern Team site.
Use the script below to create a new Communications site within SharePoint Online using c# PowerShell
</p> <p># Connect to SharePoint Online<br> # This command will prompt the sign-in UI to authenticate<br> Connect-PnPOnline "https://tenant.sharepoint.com/" –Credentials (Get-Credential)</p> <p># Create the new "modern" team site<br> $teamSiteUrl = New-PnPSite -Type CommunicationSite -Title "MY SITE TITLE" -Description "This is my description of the site" -Url https://tenant.sharepoint.com/sites/MYSITEURL<br> # Connect to the modern site using PnP PowerShell SP cmdlets<br> # Since we are connecting now to SP side, credentials will be asked<br> Connect-PnPOnline $teamSiteUrl</p> <p># Now we have access on the SharePoint site for any operations<br> $context = Get-PnPContext<br> $web = Get-PnPWeb<br> $context.Load($web, $web.WebTemplate)<br> Invoke-PnPQuery<br> $web.WebTemplate + "#" + $web.Configuration</p> <p>