Create a Communication Site in SharePoint Online using PowerShell

Requirement: Create a communication site in SharePoint Online using PowerShell

How to Create a Communication Site in SharePoint Online?
One of the recent addition to SharePoint Online space is Communication sites! The modern SharePoint Online communication site templates are designed to broadcast information to a broader audience such as to an entire organization or teams to keep them informed and engaged. You can share news, reports, images, documents, organizational events and other information in a visually compelling format that communicates key information into one central place. A communication site is more visual-centric, dynamic sites that look great on the web, on a PC or Mac, on mobile browsers, and in the SharePoint app. Communication sites allow people to create and share timely updates that go beyond email, Anyone can easily create communicate sites and customize within 30 minutes!

Communication sites provide configurable templates for the sites and pages to make your life easy while communicating messages to a large audience. When you create a communication site in SharePoint, you can start with a blank site or choose one of the available site designs, each of which comes with a default set of web parts with preset designs to help users get started, faster.

Create a New Communication Site in SharePoint Online
To create a communication site in SharePoint Online, follow these steps:
  • Login to New SharePoint Admin Center as a tenant admin or SharePoint Online Administrator. 
  • Click on "Sites" >> "Active Sites" from left navigation >> Click on "Create" >> From the  options available, choose "Communication Site " to create a new communication site collection.
    create communication site sharepoint online powershell
  • Give the site a name, which becomes the URL of the site. You can edit URL as well below it if needed. These sites are created under the /sites managed path by default.
  • Choose a template for your site - it is just a starting layout, you can change it later anyway. I've selected "Topic" here!
    how to create communication site in sharepoint online
  • Optionally, under the "Advanced settings", select the language and set the description by adding some text that lets people know the purpose of your site and then click Finish.
SharePoint creates the communication site quickly and will appear on the sites list. Now, we can populate it with our own information. When ready, You can share it with other people by adding the permissions and sharing it with others. Communication sites don't come with an Office 365 group. 
create new communication site sharepoint online

You can also use the "SharePoint Home" (https://tenant.sharepoint.com/_layouts/15/sharepoint.aspx) to create communication sites by simply going to: Office 365 App Launcher, click on SharePoint.
create modern communication site sharepoint
Here is where communication site templates fits well:
  • A typical Intranet-Extranet-department sites.
  • News Portals, Product or Service oriented sites,
  • Campaigns, insights, Events, usiness highlights and reviews
Alright, let's create a communication site in SharePoint Online with PowerShell!

Create SharePoint Online communication site with PowerShell
#Define Parameters
$AdminCenterURL = "https://crescent-admin.sharepoint.com/"
$SiteURL = "https://crescent.sharepoint.com/sites/communications"
$SiteTitle = "Communication Site"
$SiteOwner = "Salaudeen@crescent.com"

#Connect to SharePoint Online
Connect-SPOService -Url $AdminCenterURL -Credential (Get-Credential)

#PowerShell to Create new communication site
New-SPOSite -Url $SiteURL -Owner $SiteOwner -Template "SITEPAGEPUBLISHING#0" -StorageQuota 2048 -Title $SiteTitle
Let's add some error handling to the above script and re-write it in PnP PowerShell.

Create a Communication site in SharePoint Online using PnP PowerShell
Here is how to create a communication site using PnP PowerShell
New-PnPSite -Type CommunicationSite -Title Intranet -Url https://crescent.sharepoint.com/sites/Intranet -SiteDesign Showcase

and bit expanded one goes here:
#Define Config Variables
$AdminCenterURL = "https://crescent-Admin.sharepoint.com"
$SiteURL = "https://crescent.sharepoint.com/sites/intranet"
$SiteTitle = "Crescent Intranet Portal"
$SiteOwner = "Salaudeen@crescent.com"
$Template = "SITEPAGEPUBLISHING#0" #Communication Site template
$Timezone = 24 #(GMT+04:00) Abu Dhabi, Muscat
 
#Get Credentials to connect
$Cred = Get-Credential
 
Try
{
    #Connect to Tenant Admin
    Connect-PnPOnline -URL $AdminCenterURL -Credential $Cred
     
    #Check if site exists already
    $Site = Get-PnPTenantSite | Where {$_.Url -eq $SiteURL}
 
    If ($Site -eq $null)
    {
        #sharepoint online pnp powershell to create communication site
        New-PnPTenantSite -Url $SiteURL -Owner $SiteOwner -Title $SiteTitle -Template $Template -TimeZone $TimeZone -RemoveDeletedSite
        write-host "Site Collection $($SiteURL) Created Successfully!" -foregroundcolor Green
    }
    else
    {
        write-host "Site $($SiteURL) exists already!" -foregroundcolor Yellow
    }
}
catch {
    write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}
Create a Communication Site in SharePoint Online using PowerShell Create a Communication Site in SharePoint Online using PowerShell Reviewed by Salaudeen Rajack on December 25, 2019 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.