Jerry i've managed to fix the issue using another script here below thanks for your responses
Unable to remove the SPO site header using PNP shell
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
1 additional answer
Sort by: Most helpful
-
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.