kwizcom banner advertisement

SharePoint Online: Change Welcome Page using PowerShell

How to change welcome page in SharePoint Online?
To set welcome page in SharePoint online, Navigate to:
  • Site Settings  >> Click on "Welcome page" under Look and Feel
  • Use browse or directly type any any existing page in the site to change the welcome page. 
    change welcome page sharepoint online
  • Click OK to save your changed.
PowerShell to change welcome page SharePoint Online:
Use this PowerShell script to change 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
}
SharePoint Online: Change Welcome Page using PowerShell SharePoint Online: Change Welcome Page using PowerShell Reviewed by Salaudeen Rajack on 12:02 PM Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.