I am trying to modify a PowerShell script to add Links to the SharePoint Online Global Navigation bar of my sites. I currently have a script which will add a "Header" to the Global Navigation Bar, but rather than add headers, I need to modify it to add “Links”.

Referencing the diagram below, I need the new link to appear as the example “Link1” Currently I can only add a header with the attached script which appears like the example “Hello1” below. Does anyone know how I can modify my script to make the Global Navigation item appear as a link?

Settings View

Script which adds a “Header”"

siteUrl = $_.Url
$siteTitle = $_.Title
$context = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
 $context.Credentials = $credentials 
$context.RequestTimeOut = 5000 * 60 * 10; 
$web = $context.Web 
$site = $context.Site 
$NavBar = $context.Web.Navigation.TopNavigationBar 
$NavigationNode = New-Object Microsoft.SharePoint.Client.NavigationNodeCreationInformation
$NavigationNode.Title = $ItemName
$NavigationNode.Url = $ItemUrlPath
$NavigationNode.AsLastNode = $true           

Check out https://github.com/SharePoint/PnP-PowerShell/blob/master/Documentation/AddPnPNavigationNode.md

Connect-PnPOnline -Url $_.Url
Add-PnPNavigationNode -Title $ItemName -Url <whatever you want> -Location TopNavigationBar -Header $ItemName

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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