SharePoint Online: Change Welcome Page using PowerShell

Requirement: Set the 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. Remember that you must be a site collection administrator to make the changes. Let’s get started!

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

  1. Settings >> Site Settings  >> Click on “Welcome page” under Look and Feel
  2. Use the browse button or directly type any existing page on the site to change the welcome page. 
    change welcome page sharepoint online
  3. Click OK to save your changes.

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 - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

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

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

    Reply

Leave a Reply

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