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:

Learn more
- Set up a home site in SharePoint Online using PowerShell
- SharePoint Online: Apply JSON View formatting using PnP PowerShell
- SharePoint Online: Apply JSON View formatting using CLI for Microsoft 365
- SharePoint Online: Empty Recycle Bin using PnP PowerShell
- Change SharePoint Online List URL using PnP PowerShell
- Update SharePoint Page Banner Image using PnP PowerShell
- Add/Update image columns in SharePoint/Microsoft Lists using PnP PowerShell
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
![]()