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

Mohammed 81 Reputation points

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


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


    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.

    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.