Error adding navigation link to SharePoint site

Robbert van Andel
Occasional Contributor

I have a powershell script that automates the creation of an Office 365 group and configures the associated SharePoint site.  The following code adds a link to the left navigation of the site. 

$ctx = Get-PnPContext;
$finalizeLinkAdded = $false;
try {
  $web = $ctx.Web
  $navColl = $web.Navigation.QuickLaunch
  $ctx.Load($navColl) ;       

  $newNavNode = New-Object Microsoft.SharePoint.Client.NavigationNodeCreationInformation
  $newNavNode.Title = "Link Title"
  $newNavNode.Url = $linkToAdd
  $newNavNode.AsLastNode = $true

  $navColl.Add($newNavNode) | out-null;

  $finalizeLinkAdded = $true;
catch {

I have connected to the site using connect-pnponline (not shown in the snippet below).  This works fine when I run the script from my console.  However, this script is called using a job.

$job = Start-Job -InitializationScript { d:\powershell\assemblies.ps1}  -ScriptBlock { d:\powershell\create-navigation.ps1 } 

When the script is called this way, I get a weird error.

Cannot convert argument "parameters", with value: "Microsoft.SharePoint.Client.NavigationNodeCreationInformation", 
for "Add" to type "Microsoft.SharePoint.Client.NavigationNodeCreationInformation": 
"Cannot convert the "Microsoft.SharePoint.Client.NavigationNodeCreationInformation" value 
of type "Microsoft.SharePoint.Client.NavigationNodeCreationInformation" to 
type "Microsoft.SharePoint.Client.NavigationNodeCreationInformation"."

Am I missing something?

1 Reply

I ended up posting this somewhere else thinking it was deleted since I didn't see it after posting.  The answer was simple


Add-PnPNavigationNode -Location "QuickLaunch" -Title "Link" -url $Linkurl
Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
50 Replies
Extentions Synchronization
Deleted in Discussions on
3 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
32 Replies
Security Community Webinars
Valon_Kolica in Security, Privacy & Compliance on
15 Replies
Dev channel update to 80.0.355.1 is live
josh_bodner in Discussions on
67 Replies