NavigationNode Id’s for PnP PowerShell in SharePoint

February 7th, 2019 | Posted by Marijn in code | PnP Powershell | sharepoint

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 🙂

You can follow any responses to this entry through the RSS 2.0 You can leave a response, or trackback.

Leave a Reply

%d bloggers like this: