Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#3,959 7 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
powershell
Ambito
cli

Direzione di ricerca

Inizia riproducendo il problema con Connect-PnPOnline e Add-PnPPage -Name "Welcome" -LayoutType Home nell’ambiente segnalato. Ispeziona il punto di ingresso di Add-PnPPage e il comportamento del file generato; il lavoro è completato quando il comando crea una pagina moderna utilizzabile invece di generare l’errore di riferimento null e produrre un file danneggiato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
C#
Stelle
905
Fork
409
Merge medio
2g 9h
PR unite (30g)
10

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di pnp/powershell

Tutte le issue di pnp/powershell

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.