I want to create top link navigation items via powershell script to multiple sub sites, can anyone help?

You may wonder why can't we add it manually via navigation, I'm using SharePoint 2019 communication template and it has more than 50 sub sites which need same navigation which I'm not able to achieve as enabling publishing infrastructure feature is throwing error, I have created separate question for that.

1 Answer 1


Even without powershell (edit: or publishing enabled), subsites can inherit the top nav from their parent site. See site settings --> top link bar --> "use links from parent"

if you want to go the powershell route, the pnp powershell library has a cmdlet for this: Add-PnPNavigationNode. The docs with code examples are here. This cmd will work on the "current" site you connected to, but also supports an optional web parameter. To loop through all sites, we can use get-pnpsubwebs. Putting them together looks something like this:

get-pnpsubwebs -recurse | % { add-pnpnavigationnode -title Bing -url http://www.bing.com -location TopNavigationBar -external -web $_.id }
  • As i mentioned before, I had tried the first option which is the easy one but it doesn't work in SP 2019 communication template. I will try the powershell option and let you know
    – Sivanrv
    Jan 24, 2019 at 12:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.