Convert classic team site to communication site in SharePoint Online

Convert classic team site to communication site in SharePoint Online

No comments

 1,074 total views,  17 views today

In this tutorial, we will learn how to convert a classic team site to a communication site in SharePoint online using the PowerShell script and PnP PowerShell. Before that, we will recap about what is communication site and classic team site in SharePoint Online.

Key-Highlights

  • What is a communication site in SharePoint Online?
  • What is a classic team site in SharePoint Online?
  • Prerequisites to convert a classic team site to communication site in SharePoint Online
  • Using the PowerShell script how to converts a classic team site to a communication site?
  • Let’s verify the classic team site before conversion in SharePoint Online
  • How to execute the site conversion script?
  • Let’s verify the classic team site after the conversion to communication site in SharePoint Online
  • What exactly internally happens when we convert a classic team site to a communication site?
  • How to convert a classic team site to a communication site using the PnP PowerShell script?

What is a communication site in SharePoint Online?

In SharePoint, there are lots of out of the box site templates, like, team site, blog site, document center, wiki site, etc, a communication site template is one among them. As each site templates have their own scopes and needs, a communication site also has its needs significant meaning. We can say a SharePoint communication site is a great tool for sharing information with others in the organization, using the communication site users can share news, reports, statuses, and other information.

What is a classic experience team site in SharePoint Online?

It is the same team site of SharePoint on-premise where people generally use this for collaboration between team members and share the document – this is the online version of the team site which uses the classic UI (experiences).

Now with this conversion (communication to classic team site) technique, any classic team site can have the communication site’s capability in the classic team site. By running a PowerShell command, we can bring modern communication site features to the classic team sites.

Please read my previous article on the team site and communication site from here – Create a modern team site using PnP PowerShell in SharePoint

Prerequisites to convert a classic team site to communication site in SharePoint Online

  • The site must be a classic team site that’s not connected to a Microsoft 365 group (the STS #0 site template).
  • The site must be the top-level site in the site collection. It can’t be a subsite.
  • The user who runs the PowerShell cmdlet must have a full owner or site collection administrator permission on the target site.
  • The site must not have SharePoint Server Publishing Infrastructure enabled at the site collection level or SharePoint Server Publishing enabled at the site level.

Using the PowerShell script how to converts a classic team site to a communication site

Using the below PowerShell script we can convert a classic team site to a communication site:


#################PowerShell script to convert a classic team site to communication site#####################################

cls

$fileName = "Convert_Site_Report"
#'yyyyMMddhhmm yyyyMMdd
$enddate = (Get-Date).tostring("yyyyMMddhhmmss")
$logFileName = $fileName +"_"+ $enddate+"_Log.txt"
$invocation = (Get-Variable MyInvocation).Value
$directoryPath = Split-Path $invocation.MyCommand.Path

$directoryPathForLog=$directoryPath+"\"+"LogFiles"
if(!(Test-Path -path $directoryPathForLog))
{
New-Item -ItemType directory -Path $directoryPathForLog
#Write-Host "Please Provide Proper Log Path" -ForegroundColor Red
}
#$logPath = $directoryPath + "\" + $logFileName

$logPath = $directoryPathForLog + "\" + $logFileName

$isLogFileCreated = $False
function Write-Log([string]$logMsg)
{
if(!$isLogFileCreated){
Write-Host "Creating Log File..."
if(!(Test-Path -path $directoryPath))
{
Write-Host "Please Provide Proper Log Path" -ForegroundColor Red
}
else
{
$script:isLogFileCreated = $True
Write-Host "Log File ($logFileName) Created..."
[string]$logMessage = [System.String]::Format("[$(Get-Date)] - {0}", $logMsg)
Add-Content -Path $logPath -Value $logMessage
}
}
else
{
[string]$logMessage = [System.String]::Format("[$(Get-Date)] - {0}", $logMsg)
Add-Content -Path $logPath -Value $logMessage
}
}
try
{
$siteURL="https://globalsharepoint2020.sharepoint.com/sites/TestClassicTeamSite/"
$adminSiteURL="https://globalsharepoint2020-admin.sharepoint.com"
$userName = "Global-sharepoint2020@globalsharepoint2020.onmicrosoft.com"
$passWord = "YourSPOPassword"
$encPassWord = convertto-securestring -String $passWord -AsPlainText -Force
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $userName, $encPassWord

#$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteURL)
#$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userName, $encPassWord)
Connect-SPOService -Credential $cred -Url $adminSiteURL

Enable-SPOCommSite -SiteUrl $siteURL

Write-Host "The site has been successfully converted to communication site" -ForegroundColor Green

}

Catch
{
$ErrorMessage = $_.Exception.Message +"in converting to communication site:"
Write-Host $ErrorMessage -BackgroundColor Red
Write-Log $ErrorMessage
}

#################PowerShell script to convert a classic team site to communication site - ends here##########################

Let’s verify the classic team site before conversion in SharePoint Online

Below is the example of the classic team site before the conversion in SharePoint Online, in this demo, we will convert this classic team site into a communication site using the PowerShell script.

Classic Team site before conversion in SharePoint Online
Classic Team site before conversion in SharePoint Online

How to execute the site conversion script?


$siteURL="Your classic team site URL which you want to convert"

$adminSiteURL="Your tenant SharePoint admin center URL"

$userName = "Your Global Admin User Name"

$passWord = "YourSPOPassword"

Once we execute the above script, we will get the below confirmation message “This action is permanent and cannot be undone. Are you sure you want to proceed?”

Click on the “Yes” button.

This action is permanent and cannot be undone. Are you sure you want to proceed?
This action is permanent and cannot be undone. Are you sure you want to proceed?

Let’s verify the classic team site after the conversion to communication site in SharePoint Online

Now if we access the same classic team site URL, we could see a different look and feel i.e. communication site look and feel.

Classic team site after the conversion to communication site in SharePoint Online
Classic team site after the conversion to communication site in SharePoint Online

What exactly internally happens when we convert a classic team site to a communication site?

  • A new modern page will be created on the site and set as the home page. We can open the site in a new tab to see the changes.
  • Any user that has access to the site will see the new home page with the default web parts and content immediately.
  • Until you’re ready to launch the new communication site experience, you can change the home page back to the former page.
  • Full-width pages with horizontal navigation are available.
  • The top navigation from the classic view is hidden but can be seen on classic pages like the site settings page.
  • You can now customize the navigation on this site.
  • The custom script isn’t allowed on the site.
  • Minor versioning on the Site Pages library is enabled.
  • No site permissions are changed.
  • The SharePoint lists and libraries experience isn’t changed.
  • Any content types enabled on the site aren’t changed.
  • If the classic site collection had subsites, they aren’t changed.

How to convert a classic team site to communication site using the PnP PowerShell script

The way we have converted a classic team site to a communication site using the PowerShell script, similarly, we can convert the classic site team site to a communication site using the PnP PowerShell.


#################Convert a classic team site to a communication site using the PnP PowerShell#####################################

cls

$fileName = "Convert_Site_Report"
#'yyyyMMddhhmm yyyyMMdd
$enddate = (Get-Date).tostring("yyyyMMddhhmmss")
$logFileName = $fileName +"_"+ $enddate+"_Log.txt"
$invocation = (Get-Variable MyInvocation).Value
$directoryPath = Split-Path $invocation.MyCommand.Path

$directoryPathForLog=$directoryPath+"\"+"LogFiles"
if(!(Test-Path -path $directoryPathForLog))
{
New-Item -ItemType directory -Path $directoryPathForLog
#Write-Host "Please Provide Proper Log Path" -ForegroundColor Red
}
#$logPath = $directoryPath + "\" + $logFileName

$logPath = $directoryPathForLog + "\" + $logFileName

$isLogFileCreated = $False
function Write-Log([string]$logMsg)
{
if(!$isLogFileCreated){
Write-Host "Creating Log File..."
if(!(Test-Path -path $directoryPath))
{
Write-Host "Please Provide Proper Log Path" -ForegroundColor Red
}
else
{
$script:isLogFileCreated = $True
Write-Host "Log File ($logFileName) Created..."
[string]$logMessage = [System.String]::Format("[$(Get-Date)] - {0}", $logMsg)
Add-Content -Path $logPath -Value $logMessage
}
}
else
{
[string]$logMessage = [System.String]::Format("[$(Get-Date)] - {0}", $logMsg)
Add-Content -Path $logPath -Value $logMessage
}
}
try
{
$siteURL="https://globalsharepoint2020.sharepoint.com/sites/TestClassicTeamSite/"
$adminSiteURL="https://globalsharepoint2020-admin.sharepoint.com"
$userName = "Global-sharepoint2020@globalsharepoint2020.onmicrosoft.com"
$passWord = "YourSPOPassword"
$encPassWord = convertto-securestring -String $passWord -AsPlainText -Force
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $userName, $encPassWord

#$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteURL)
#$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userName, $encPassWord)
#Connect-PnPOnline –Url <Url of Targetsite> –Credentials (Get-Credential)
Connect-PnPOnline -Url $siteURL -Credentials $cred

Enable-PnPCommSite

Write-Host "The site has been successfully converted to communication site" -ForegroundColor Green

}

Catch
{
$ErrorMessage = $_.Exception.Message +"in converting to communication site:"
Write-Host $ErrorMessage -BackgroundColor Red
Write-Log $ErrorMessage
}

#################Convert a classic team site to a communication site using the PnP PowerShell - ends here##########################

Summary:

Thus, in this article, we have learned the below with respect to converting a classic team site to communication site:

  • What is a communication site in SharePoint Online?
  • What is a classic team site in SharePoint Online?
  • Prerequisites to convert a classic team site to communication site in SharePoint Online
  • Using the PowerShell script how to converts a classic team site to a communication site?
  • How to execute the team site to the communication site conversion script?
  • What exactly internally happens when we convert a classic team site to a communication site?
  • How to convert a classic team site to a communication site using the PnP PowerShell script?

See Also

You may also like the following SharePoint PowerShell tutorials:

Free download SharePoint Online & Office 365 Administration eBook(238 Pages)

Get the PDF eBook from here:


[purchase_link id="0" style="button" color="blue" text="Free Download SharePoint Online & Office 365 Administration"]

 

 
FREE DOWNLOAD

Send download link to:

Subscribe to get exclusive content and recommendations every month. You can unsubscribe anytime.