Vue normale

Il y a de nouveaux articles disponibles, cliquez pour rafraîchir la page.
À partir d’avant-hierFlux principal

Set SharePoint site home page using PnP PowerShell and CLI for Microsoft 365

SharePoint site home page provides a centralized location where users can access important information such as news, announcements, quick links and documents. This can help users stay informed and up-to-date on the latest company news and updates.

SharePoint site home page can be customized to include quick links to commonly used tools and applications, which can help users save time and increase productivity.

In this blog, we will look at how to use PnP PowerShell and CLI for Microsoft 365 to set a SharePoint modern page as the home page for SharePoint online site. You can use either of below scripts to make a newly created site page or an existing site page as the homepage for your SharePoint site.

Using PnP PowerShell

Once you have a modern site page ready in Site Pages library of your SharePoint site, you can use below PnP PowerShell script to make your site page as the homepage of your SharePoint site:

# SharePoint online site URL
$siteUrl = "https://contoso.sharepoint.com/sites/SPConnect"

# Name of your SharePoint site page
$sitePageName = "NewHome.aspx"

# Connect to SharePoint online site
Connect-PnPOnline -Url $siteUrl -Interactive

# Set SharePoint site home page using PnP PowerShell
Set-PnPHomePage -RootFolderRelativeUrl SitePages/$sitePageName

Using CLI for Microsoft 365

You can use below CLI for Microsoft script to set your site page as the homepage of your SharePoint online site:

# SharePoint online site URL
$siteUrl = "https://contoso.sharepoint.com/sites/SPConnect"

# Name of your SharePoint site page
$sitePageName = "NewHome.aspx"

#Get Credentials to connect
$m365Status = m365 status
if ($m365Status -match "Logged Out") {
    m365 login
}

# Set SharePoint site home page using CLI for Microsoft 365
m365 spo web set --url $siteUrl --welcomePage "SitePages/$sitePageName"

Note

You have to install latest versions of PnP PowerShell and CLI for Microsoft 365 before running above scripts. Follow below documentations for installing PnP PowerShell and CLI for Microsoft 365:

Once you run either of above scripts successfully and navigate to SharePoint online site, you will see that new home page is set for your SharePoint online site:

Set SharePoint online site home page using PnP PowerShell and CLI for Microsoft 365 in modern experience
Set SharePoint site home page using PnP PowerShell and CLI for Microsoft 365

Learn more

set-sharepoint-site-home-page-using-pnp-powershell-and-cli-for-microsoft-365

ganeshsanapblogs

Set SharePoint online site home page using PnP PowerShell and CLI for Microsoft 365 in modern experience

Set up a home site in SharePoint Online

Microsoft is currently rolling out SharePoint app bar and Global navigation to SharePoint online tenants. By default the home icon in app bar is linked to the SharePoint start page. To change this behavior, you need to enable the global navigation. Enabling and customizing global navigation in SharePoint requires a home site.

SharePoint online home site is also required to use Microsoft Viva connections in Microsoft Teams desktop client.

So, if you are planning to customize the global navigation or use Microsoft Viva connections in Microsoft Teams, first you have to set up a home site for your SharePoint online tenant. Home site is a SharePoint site that you create and set as the top landing page for all users in your intranet. You can set only one SharePoint site as a home site which must be a communication site.

Steps to set a site as your home site

  1. Create a communication site to set it as the home site or use existing communication site.
  2. Customize the communication site by adding navigation, header, footer, site logo, news, events and other web parts as per your requirements and brand.
  3. Use PowerShell commands to set a communication site as the home site.

Use PowerShell to set a communication site as the home site

After you create and customize the communication site that you want to use as your home site, you need to run a PowerShell commands to set it as your home site. To run this commands, you must be a global admin or SharePoint admin in your Microsoft 365 tenant.

Using SharePoint Online PowerShell

1. Download the latest version of SharePoint Online Management Shell.

2. Connect to SharePoint admin site as a global admin or SharePoint admin using below command:

Connect-SPOService -Url https://<tenant>-admin.sharepoint.com

3. Run below command to set a communication site as the home site:

Set-SPOHomeSite -HomeSiteUrl https://<tenant>.sharepoint.com/sites/<communicationsite>
Using PnP PowerShell

You can use PnP PowerShell Set-PnPHomeSite command to set the home site for your SharePoint tenant.

Connect-PnPOnline -Url https://<tenant>-admin.sharepoint.com/ -Interactive
Set-PnPHomeSite -HomeSiteUrl "https://<tenant>.sharepoint.com/sites/<communicationsite>"
Using CLI for Microsoft 365

You can use CLI for Microsoft 365 spo homesite set command to set the specified communication site as the Home Site.

m365 login
m365 spo homesite set --siteUrl https://<tenant>.sharepoint.com/sites/<communicationsite>

Points to remember

  • Only one communication site can be set as the home site.
  • Search scope for the site will be changed to tenant-wide search.
  • The site will be automatically set up as an organization news site.
  • The first time you set up a home site, it might take up to several minutes for the changes to take effect.
  • If you run the above command again to switch your home site to a different site, it might take up to 2 hours.
  • Home site can be registered as a hub site, but it can’t be associated with a hub.

Unregister a home site from your tenant

If you have registered a site as a home site in your tenant previously and now you don’t want to have any home site in your tenant, you need to run the following PowerShell command with administrator privileges:

Remove-SPOHomeSite

This removes the current SharePoint Online Home Site setting. Note that you do not need to specify the URL of your home site.

Learn more

❌
❌