DEV Community

Tony Watters
Tony Watters

Posted on • Edited on

3 1

PnP PowerShell adding navigation links

How to add a Navigation link with child links to numerous sites with PnP PowerShell

$tenantUrl = "https://YOURTENENT.sharepoint.com/"

$cred = Get-Credential

$sites = "Site1", "Site2", "Site3", "Site4"

foreach($name in $sites) {  

    Connect-PnPOnline -Url "$tenantUrl/sites/$name/SitePages/" -Credentials $cred

    Add-PnPNavigationNode -Title "Parent Link" -Url "$tenantUrl/sites/mysite/SitePages/somesite1.aspx" -Location "QuickLaunch"
    Add-PnPNavigationNode -Title "Child one" -Url "$tenantUrl/sites/mysite/SitePages/somesite2.aspx" -Location "QuickLaunch" -Header "Parent Link" 
    Add-PnPNavigationNode -Title "Child two" -Url "$tenantUrl/sites/mysite/SitePages/somesite3.aspx" -Location "QuickLaunch" -Header "Parent Link" 
    Add-PnPNavigationNode -Title "Child three" -Url "$tenantUrl/sites/mysite/SitePages/somesite4.aspx" -Location "QuickLaunch" -Header "Parent Link" 
    Add-PnPNavigationNode -Title "Child four" -Url "$tenantUrl/sites/mysite/SitePages/somesite5.aspx" -Location "QuickLaunch" -Header "Parent Link" 
}
Enter fullscreen mode Exit fullscreen mode

Checkout these excellent PowerShell resources

My good friend Velin Georgiev blog is an excellent resource on all things SharePoint
https://blog.velingeorgiev.com/provision-custom-list-sharepoint-pnp-powershell

Also found this great Cheat sheet
http://compari.tech/powershell

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay