Articles about European Sharepoint Hosting Service
SharePoint Hosting – Copy Navigation Using PowerShell
In this blog, we have discussed the copy of the navigation menu from one site to another site using a PowerShell script in SharePoint online. There are 3 types of Navigation in SharePoint Online,
- Site Navigation (Local Navigation)
- Global Navigation
- Hub Site (Tenant) Navigation).
Site Navigation
Site Navigation is also known as the Quick Launch Navigation or Local navigation. A user can access anything related to this site within one click by using this navigation. If you have a Team Site, it has navigation on the left side of the site. If you have a communication site the Quick Launch is on the top of the site.
Global Navigation (Tenant Navigation)
In Global Navigation users can access to any site in the same site collection.
Hub Navigation
Hub site navigation appears at the top of the site and it is global navigation. One would create a link in the sites that are part of the hub site.
In this blog, we will learn how to copy the navigations from one site to another using PowerShell PnP.
Copy hub Navigation
Follow the below code to copy Hub navigation from one site to another site.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
Param( [Parameter(ParameterSetName = "Inputparameter", Position = 1, Mandatory = $True)] [String] $sourceHubsiteUrl, [Parameter(ParameterSetName = "Inputparameter", Position = 2, Mandatory = $True)] [String] $destinationHubsiteUrl) Add - Type - AssemblyName PresentationFramework Function Copy - NavigationToplink($sourceHubsiteUrl, $destinationHubsiteUrl) { $getTopNavs = Get - NavigationToplink - Hubsite $sourceHubsiteUrl Add - NavigationToplink - Topnavs $getTopNavs - Hubsite $destinationHubsiteUrl } Function Get - NavigationToplink($hubsite, $Credentials) { [System.Windows.MessageBox]::Show("Please provide credentials for login to the ($hubsite) Site") Connect - PnPOnline - Url $hubsite - UseWebLogin $topNavs = Get - PnPNavigationNode - Location TopNavigationBar | Select Title, Url Disconnect - PnPOnline return $topNavs } Function Add - NavigationToplink($topNavs, $hubsite) { [System.Windows.MessageBox]::Show("Please provide credentials for login to the ($hubsite) Site") Connect - PnPOnline - Url $hubsite - UseWebLogin foreach($topNav in $topNavs) { if ($TopNav.Url) { $navUrl = $topNav.Url $navTitle = $topNav.Title Add - PnPNavigationNode - Location TopNavigationBar - Title $navTitle - Url $navUrl } } } Copy - NavigationToplink - SourceHubsiteUrl $sourceHubsiteUrl - DestinationHubsiteUrl $destinationHubsiteUrl |
Source site image
Destination site image
Copy quick launch Navigation
Follow the below code to copy the quick launch from one site to another site.
Source Site Image
Destination site image
Conclusion
The above-mentioned script can be used to copy all types of Navigation from one site to another which can be really a great time saver script. If some navigation is getting changed in the site as per the requirement of the organization, then one can use this script to copy all the navigation options from one site to another which is really helpful.
Print article | This entry was posted by Peter on August 5, 2021 at 2:00 am, and is filed under European SharePoint 2013 Hosting. Follow any responses to this post through RSS 2.0. Both comments and pings are currently closed. |