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
MSTeams Groups in outlook with macros disabled
ReadyorNot in Microsoft Teams on
0 Replies
Unknown Login Error
Alex_P3462 in Microsoft Teams on
0 Replies
Make Share function in Edge more useful
HotCakeX in Discussions on
2 Replies
Spelling Pop-Up Stuck on SharePoint List
aricornish in SharePoint on
0 Replies
Problem with OneDrive
esholder in OneDrive for Business on
5 Replies