Convert classic team site to communication site in SharePoint Online

Convert classic team site to communication site in SharePoint Online

No comments

Loading

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

Key-Highlights: convert 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 a communication site in SharePoint Online
  • Using the PowerShell script how to convert 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 the 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 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 its 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 (classic team site sharepoint)?

It is the same team site of SharePoint on-premise that people generally use for collaboration between team members and sharing 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 a 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.

Convert classic team site communication site using PowerShell

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 (convert classic team site to communication site)

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.

Convert classic team site to communication site, Classic Team site before conversion in SharePoint Online
Classic Team site before conversion in SharePoint Online

How to execute the site conversion script (convert classic team site communication site using PowerShell)?


$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 - convert classic team site communication site using PowerShell
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 the 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.

Convert classic team site to communication site, 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 (Convert team site to communication site PowerShell)?

  • 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 a communication site using the PnP PowerShell script (convert team site to communication site PowerShell)?

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: Convert classic team site to communication site (Convert team site to communication site PowerShell)

Thus, in this article, we have learned the below with respect to converting a classic team site to a 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 a communication site in SharePoint Online
  • Using the PowerShell script how to convert 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: SharePoint Online PowerShell Tutorial

You may also like the following SharePoint PowerShell tutorials:

Download SharePoint Online PDF Book

Download SharePoint Online & Office 365 Administration eBook

Buy the premium version of SharePoint Online & Office 365 administration eBook from here:



Buy SharePoint Online & Office 365 Administration eBook


 

Get the free demo PDF eBook from here:

FREE DOWNLOAD

Send download link to:

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

 

 

 

About Post Author

Do you have a better solution or question on this topic? Please leave a comment