SharePoint Online: How to Change Site Title (Name) using PowerShell?

Requirement: Change the Site Title in SharePoint Online.

SharePoint Online: How to Change the Title of a Site Collection?
How to change the name of a SharePoint Online site? Well, To change the site collection title in SharePoint Online, follow these steps:
  • Go to Site Settings Page >> Click on "Title, Description, and Logo" link under "Look and Feel"
  • Enter the new title for your site or site collection
    change site collection title in sharepoint online using powershell
  • Click "OK" to save your changes. This changes the site name. Now, lets use PowerShell to change site name in SharePoint Online.

How to Change Site Name in Modern SharePoint Online Sites?
Site names are given at the time of creating site collections or subsites. However, If you want to change the site name, follow below steps:
  • Login to the site where you want to change name. Click on Settings gear >> Click on "Site Information" link. 
  • Enter the Site name value and hit Save to change the name to your SharePoint site.
    sharepoint online how to change site name
In the "Site Information" panel you can update the Site description as well and click on "Save" button.

PowerShell to Change Site Title in SharePoint Online:
Alright, Let's see the PowerShell script to change SharePoint Online site name. Here is the PowerShell to change site or site collection title in SharePoint Online.
#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

#Variables
$SiteURL="https://crescenttech.sharepoint.com/us"
$NewSiteTitle="United States"

Try {
    $Cred= Get-Credential
    $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
 
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = $Credentials

    #Get the Site from URL
    $Web = $Ctx.web
    $Ctx.Load($web)
    $Ctx.ExecuteQuery()
 
    #Get the current site title
    Write-host "Site Title:"$web.title

    #sharepoint online powershell change site title
    $web.title = $NewSiteTitle
    $Web.Update()
    $Ctx.ExecuteQuery()
     
    Write-host "Site Title has been updated to '$NewSiteTitle'" -ForegroundColor Green  
}
Catch {
    write-host -f Red "Error Updating Site Title!" $_.Exception.Message
}
This PowerShell changes the site collection name to new name.

SharePoint Online: Change Site Name using PnP PowerShell
Here is the PnP PowerShell to change site name in SharePoint Online
#Config Variables
$SiteURL = "https://crescenttech.sharepoint.com/Sales"
 
#Connect to PNP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)

#sharepoint online powershell change site name
Set-PnPWeb -Title "Sales Portal" 

Change SharePoint Online site description using PowerShell
Similarly, you can update the description of the site using "-Description" parameter.
Set-PnPWeb -Description "Marketing Portal"

To change the site URL in SharePoint Online, use How to change the Site URL in SharePoint Online?

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.