NavigationNode Id’s for PnP PowerShell in SharePoint

Powershell

Disclaimer: I am not a developer, all code works on my machine, but I am sure it can be improved a lot. I am just documenting this for myself and others who might benefit from it. There is probably a better explainaition available for these NavigationNode Id’s, but I just wanted to write it down as I couldn’t find a better blogpost.

You know I love PnP PowerShell! This easy (well, easy to start with and learn) type of code (or is it script?) allow you to do a lot of really cool things that would otherwise take up a lot of time! Automating things in PowerShell is so handy! So to start off.. hats off to the guys at the PnP PowerShell!!

When I was updating some code in PowerShell, I ran across a notification when removing navigation nodes.
When I tried to do this:

Remove-PnPNavigationNode -Title "Notebook" -Location QuickLaunch -Force

I got this nice warning:

WARNING: Parameter ‘Title’ is obsolete. Use -Identity with an Id instead.

Hmm.. ok ok. While Title is super easy to use, I see why using an identity could be more useful. But where does one find these id’s ? I couldn’t really see these NavigationNode Id’s in the UI, so I went to PowerShell to give me the list:

$navNodes = Get-PnPNavigationNode -Location QuickLaunch 
Foreach ($NavNode in $navNodes)
{
  Write-Host $NavNode.id
  Write-Host $NavNode.Title

}

List of default NavigationNodes for a Team Site or a Communication site

I saw that while the navigation items for a Team site are on the left hand, and the Communication site are on top, they both are “Quicklaunch”. (I mean.. the top navigation on the Comms site is still Quicklaunch and not “TopNavigation”). So, this is the list that is created by default when you create a new site:

1031: Home
2002: Notebook
2001: Documents
2003: Pages
1034: Site contents

So if you need to remove one of the existing nodes, you can simply run this script:

Remove-PnPNavigationNode -Identity 1031

Make sure to add enough comments in the file, this might get cryptic very fast 🙂

About: Marijn

Marijn Somers (MVP) has over 14 years experience in the SharePoint world, starting out with SP2007. Over the years the focus has grown to Office 365, with a focus on collaboration and document management. He is a business consultant at Balestra and Principal Content Provider for "Mijn 365 Coach" that offers dutch employee video training. His main work tracks are around user adoption, training and coaching and governance. He is also not afraid to dig deeper in the technicalities with PowerShell, adaptive cards or custom formatting in lists and libraries. You can listen to him on the biweekly "Office 365 Distilled" podcast.