SharePoint Online: Get Site Title using PowerShell

Requirement: Get SharePoint Online site title using PowerShell

SharePoint Online: Get Site Title using PowerShell

Let’s use PowerShell CSOM script to get site title in SharePoint Online.

$AdminSiteURL = ""
$SiteURL = ""

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

#Get the Site Collection
$Site = Get-SPOSite -Identity $SiteURL

#Get Site Collection Title
Write-host $Site.Title

PowerShell to Get Site Collection Title

We can also use this PowerShell script at the site level to get the site name.

#Import PoweShell Module for SharePoint Online
Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking

$SiteUrl = ""

#Get Credentials to connect
$Cred = Get-Credential

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

    #Get the web
    $Web = $Ctx.Web

    #Get the site title
    Write-host -f Green "Site Title:" $Web.Title
catch {
    write-host "Error Getting Site Title: $($_.Exception.Message)" -foregroundcolor Red

Retrieve SharePoint Online Site Title using PnP PowerShell

$SiteURL= ""

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -UseWebLogin #-Credential (Get-Credential)

#Get the Root Web
$Web = Get-PnPWeb

#Get the Site Title
Write-host -f Green $Web.Title

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

Leave a Reply