Skip to content

Add-PnPPage: Object reference not set to an instance of an object when trying to create a new page #3959

Open
@borjaevo

Description

@borjaevo

Category

  • Bug

Describe the bug

Im trying to migrate a classic site into a modern one. I already have the connected 365 group and i can use modern lists and libraries. But i have pages, like the homepage that are classic and when this page is displayed the menu is the classic one too so the user is confused. I dont want to migrate any of those pages, i tried and get other errors so i delete all of them. Now, im trying to create a new modern page using PnP. Im using command Add-PnPPage.

Steps to reproduce

DELETE THIS LINE BEFORE SUBMITTING - Provide steps to reproduce the behavior:

  1. Im using powershell 7 and PnP installed yesterday version 2.4.0
  2. Auth using Connect-PnPOnline -Url "https://----.sharepoint.com/calidad" -Credential (Get-Credential)
  3. Execute command $pagename = "Welcome"
  4. Execute command $page = Add-PnPPage -Name $pagename -LayoutType Home
  5. See error: Add-PnPPage: Object reference not set to an instance of an object.

Expected behavior

The modern page to be created. A file is created instead but is corrupted.

Environment details (development & target environment)

  • SDK version: 2.4.0
  • OS: Windows 11

Additional context

What i want to achieve is my users only have to see one menu, and not be changing between different designs. I can't recreate the entire site because it has a lot of list with powerautomate flows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions