SharePoint Online: Change Welcome Page using PowerShell CSOM

Requirement: Set home page with PowerShell in SharePoint Online

How to change the welcome page in SharePoint Online?

Have you ever wanted to change the welcome page in SharePoint Online? It’s actually a pretty easy process, and this guide will walk you through it. Keep in mind that you’ll need to be a site collection administrator to make the changes. Let’s get started!

To set a welcome page in SharePoint Online, navigate to:

  • Settings >> Site Settings  >> Click on “Welcome page” under Look and Feel
  • Use browse or directly type any existing page in the site to change the welcome page. 
    change welcome page sharepoint online
  • Click OK to save your changed.

That’s all! With these steps, you can designate any of your custom pages as a new welcome page for your site.

PowerShell to change welcome page SharePoint Online:

Use this PowerShell script to change the welcome page of a SharePoint Online site.

#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"
  
#Set Variables for Site URL
$SiteURL= "https://crescent.sharepoint.com/sites/sales/"
$WelcomePage="SitePages/Default.aspx" #Relative path to site

#Setup Credentials to connect
$Cred = Get-Credential
$Cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)

Try {
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = $Cred

    #Set welcome page in SharePoint Online
    $Ctx.web.RootFolder.WelcomePage =$WelcomePage
    $Ctx.web.RootFolder.Update()
    $ctx.ExecuteQuery()
        
    Write-host -f Green "Welcome page updated!" 
}
Catch {
    write-host -f Red "Error setting welcome page!" $_.Exception.Message
}

To set the welcome page in SharePoint Online modern sites using PnP PowerShell, refer to How to Change the Home Page in SharePoint Online using PowerShell?

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!

One thought on “SharePoint Online: Change Welcome Page using PowerShell CSOM

  • This worked great! I spent hours trying to figure out how to fix this problem, THANK YOU!!!

    Reply

Leave a Reply