Forum Discussion
Remove the page title from a modern page as well as the white space? Someone has done it.
Hi, edit the page and the change the layout to "Plain" then run the following PowerShell script to change the Page Layout from "Article" to "Home". Make sure you use your own SharePoint URL and use the proper ID of the Page
#Connect to SharePoint Online site
$SiteURL = "https://mysite.sharepoint.com/"
Connect-PnPOnline $SiteURL -Credential (Get-Credential)
#Get the ID of the Page
Get-PnPListItem -List SitePages
#Change Page layout from "Article" to "Home"
Set-PnPListItem -List SitePages -Identity "5" -Values @{"PageLayoutType"="Home"}
Here is a post where you can find step by step details: https://jamilhallal.blogspot.com/2022/01/how-to-remove-the-top-banner-from-sharepoint-online-modern-pages.html
After I put this into PowerShell ISE, I get error message(s)
PS C:\Users\Michael's Surface> #Connect to SharePoint Online site
$SiteURL = "https://michaelq.sharepoint.com/work/"
Connect-PnPOnline $SiteURL -Credential (Get-Credential)
#Get the ID of the Page
Get-PnPListItem -List SitePages
#Change Page layout from "Article" to "Home"
Set-PnPListItem -List SitePages -Identity "7" -Values @{"PageLayoutType"="Home"}
These are the error message(s) I get
cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
Connect-PnPOnline : The term 'Connect-PnPOnline' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.
At line:3 char:1
+ Connect-PnPOnline $SiteURL -Credential (Get-Credential)
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Connect-PnPOnline:String) [], CommandNotFoundExcepti
on
+ FullyQualifiedErrorId : CommandNotFoundException
Get-PnPListItem : The term 'Get-PnPListItem' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
At line:5 char:1
+ Get-PnPListItem -List SitePages
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-PnPListItem:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Set-PnPListItem : The term 'Set-PnPListItem' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
At line:7 char:1
+ Set-PnPListItem -List SitePages -Identity "7" -Values @{"PageLayoutTy ...
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Set-PnPListItem:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException