Saturday, June 18, 2016

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
}



You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!


You might also like:

Related Posts Plugin for WordPress, Blogger...