Unable to remove the SPO site header using PNP shell

SR VSP 1,221 Reputation points
2021-03-18T19:10:00.297+00:00

Hi Guys,

I'm getting an error while removing the SPO page header (GetmyData)while running this script. And this is happening recently not sure why ? any advise
I'm running with administrator access

How to remove title header in the SPO page

$PageName = "GetMyData"
$LoginUrl = "https://contoso.sharepoint.com/sites/GetMyData"
Connect-PnPOnline -Url $LoginUrl -UseWebLogin
Set-PnPPage -Identity $PageName -LayoutType Home

79371-pnp-error.jpg

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,406 questions
SharePoint Server Management
SharePoint Server Management
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Management: The act or process of organizing, handling, directing or controlling something.
2,783 questions
0 comments No comments
{count} votes

1 additional answer

Sort by: Most helpful
  1. Jerryzy 10,561 Reputation points
    2021-03-19T03:48:25.597+00:00

    Hi @SR VSP ,

    Did the -UseWebLogin pop up a credential window for selecting the user account?

    If not, then it will will automatically use the cached credential which could be not the account who have the permission for the site, you can use

    -SPOManagementShell -ClearTokenCache append like this which will clear cached credential and force the credential window pop up:

    Import-Module -Name SharePointPnPPowerShellOnline  
      
    $PageName = "GetMyData"  
    $LoginUrl = "https://contoso.sharepoint.com/sites/GetMyData/";  
    Connect-PnPOnline -Url $LoginUrl -SPOManagementShell -ClearTokenCache;  
    Set-PnPPage -Identity $PageName -LayoutType Home  
    

    The -SPOManagementShell -ClearTokenCache needs to install the SharePointPnPPowerShellOnline (not the new PnP.PowerShell)

    Reference:

    Connect-PnPOnline: unwanted credential caching

    Thanks
    Best Regards


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.