When trying to use PNP to create SharePoint online pages I ran into this error.
Add-PnPClientSideText -Page "Offices" -Text "City office
Free phone: 12345
" -Column 2 -Section 5 -Order 5
Add-PnPClientSideText : Object reference not set to an instance of an object.
At line:1 char:1
+ Add-PnPClientSideText -Page "Offices" -Text "City office
< ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [Add-PnPClientSideText], NullReferenceException
+ FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.ClientSidePages.AddClientSideText
The error is caused by having the page open in a browser window in Edit mode.
Once you click Publish on the page in the browser the code runs fine.
Comments