Issue with replicating SharePoint Online hub site navigation to other hub sites?

Mohammed 81 Reputation points
2021-01-14T07:11:37.73+00:00

I have requirement to copy the navigation of a SharePoint hub site from one to another. I am currently using the script shared on this blog. It seems to work, but there are instances when it spits out the following error

56511-capture1.png

When it works, I noticed that only one ParentID was being printed out. However when we have multiple ParentID, the error occurs,
Has anyone ever experienced this? I really appreciate the help.

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,404 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ian Xue (Shanghai Wicresoft Co., Ltd.) 31,091 Reputation points Microsoft Vendor
    2021-01-14T09:55:22.86+00:00

    Hi,

    The parameter -Parent only accepts an Int32 so $ParentID cannot be an array. You have to pass one item of the array to the cmdlet each time.
    https://learn.microsoft.com/en-us/powershell/module/sharepoint-pnp/add-pnpnavigationnode?view=sharepoint-ps#parameters

    Best Regards,
    Ian Xue

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.