Introduction
In this blog, I have discussed how to add, retrieve, and delete the SharePoint navigation menu using PowerShell. Follow the steps to get the result.
Steps
- Get the Navigation Node
- Add the Navigation
- Remove/Delete the Navigation
In this blog, I added the coding of HubNavigation Menu but you can also Add, Retrieve and Delete the footer, Top and Hub Navigation menu from your site by running the script.
Get Top Navigation Node
Follow the below code to get the Hub Navigation menu.
- $siteURL = Read - Host "Enter site url"
- try {
- Connect - PnPOnline - Url $siteURL - Credentials(Get - Credential)
- #Get Hub Navigation and Its Sub Menu
- $topNavsMenu = Get - PnPNavigationNode - Location TopNavigationBar | Select Title, Url, Id
- foreach($topNav in $topNavsMenu) {
- Write - Host "Top Navigaion : "
- $topNav.Title
- $node = Get - PnPNavigationNode - Id $topNav.Id
- $childMenus = $node.Children | Select Title, Url, Id
- if ($childMenus - ne $null) {
- foreach($childMenus in $node.Children) {
- Write - Host "SubNavigation : "
- $childMenus.Title
- $subNodeMenus = Get - PnPNavigationNode - Id $childMenus.Id
- $subchilds = $subNodeMenus.Children | Select Title, Url, Id
- if ($subchilds - ne $null) {
- foreach($childMenus in $subchilds) {
- Write - Host $childMenus.Title
- }
- }
- }
- }
- }
- } catch {}
It is retrieving Hub navigation top, sub & child menu.
Normal 0 false false false EN-IN X-NONE X-NONE





Join the conversation! Your thoughts help the community grow.