SharePoint Online: Get Site Title using PowerShell

Requirement: Get SharePoint Online site title using PowerShell

How to Get the Site Title SharePoint Online?

You may need to quickly reference the title of a site in your reports generated from SharePoint Online sites. In this blog post, I’ll show you how to use PowerShell to get the title of a SharePoint Online site.

To get the site name or site title, Just login to the site >> Click on Settings Gear >> Choose “Site Information” >> And you’ll find the site title!

Get Site Title in SharePoint Online using PowerShell

SharePoint Online: Get Site Title using PowerShell

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

#Parameters
$AdminSiteURL = "https://crescent-admin.sharepoint.com"
$SiteURL = "https://crescent.sharepoint.com/sites/marketing"

#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 CSOM PowerShell script at the site level to get the site name.

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

#Parameter
$SiteUrl = "https://crescent.sharepoint.com/sites/marketing"

#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
    $Ctx.Load($Web)
    $Ctx.ExecuteQuery()

    #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

If you are looking for a way to get your site title in SharePoint Online using PnP PowerShell, Here you go:

#Parameters
$SiteURL= "https://crescent.sharepoint.com/sites/marketing"

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

#Get the Root Web
$Web = Get-PnPWeb

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

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

Leave a Reply

Your email address will not be published. Required fields are marked *