{"id":6872,"date":"2021-08-03T07:58:33","date_gmt":"2021-08-03T07:58:33","guid":{"rendered":"https:\/\/softreetechnology.com\/?p=6872"},"modified":"2021-08-03T07:58:35","modified_gmt":"2021-08-03T07:58:35","slug":"copy-navigation-using-powershell","status":"publish","type":"post","link":"https:\/\/softreetechnology.com\/blog\/powershell\/copy-navigation-using-powershell\/","title":{"rendered":"Copy Navigation Using PowerShell"},"content":{"rendered":"\n<p>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,<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Site Navigation (Local Navigation)<\/li><li>Global Navigation<\/li><li>Hub Site (Tenant) Navigation).<\/li><\/ol>\n\n\n\n<p><strong>Site Navigation<\/strong><\/p>\n\n\n\n<p>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&nbsp;communication site the Quick Launch is on the top of the site.<\/p>\n\n\n\n<p><strong>Global Navigation (Tenant Navigation)<\/strong><\/p>\n\n\n\n<p>In Global Navigation&nbsp;users can access to any site in the same site collection.<\/p>\n\n\n\n<p><strong>Hub Navigation<\/strong><\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>In this blog, we will learn how to copy the navigations from one site to another using PowerShell PnP.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Copy hub Navigation<\/h2>\n\n\n\n<p>Follow the below code to copy Hub navigation from one site to another site.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Param(\n    &#91;Parameter(ParameterSetName = \"Inputparameter\", Position = 1, Mandatory = $True)]\n    &#91;String] $sourceHubsiteUrl,\n    &#91;Parameter(ParameterSetName = \"Inputparameter\", Position = 2, Mandatory = $True)]\n    &#91;String] $destinationHubsiteUrl)\nAdd - Type - AssemblyName PresentationFramework\nFunction Copy - NavigationToplink($sourceHubsiteUrl, $destinationHubsiteUrl) {\n    $getTopNavs = Get - NavigationToplink - Hubsite $sourceHubsiteUrl\n    Add - NavigationToplink - Topnavs $getTopNavs - Hubsite $destinationHubsiteUrl\n}\nFunction Get - NavigationToplink($hubsite, $Credentials) {\n    &#91;System.Windows.MessageBox]::Show(\"Please provide credentials for login to the ($hubsite) Site\")\n    Connect - PnPOnline - Url $hubsite - UseWebLogin\n    $topNavs = Get - PnPNavigationNode - Location TopNavigationBar | Select Title, Url\n    Disconnect - PnPOnline\n    return $topNavs\n}\nFunction Add - NavigationToplink($topNavs, $hubsite) {\n    &#91;System.Windows.MessageBox]::Show(\"Please provide credentials for login to the ($hubsite) Site\")\n    Connect - PnPOnline - Url $hubsite - UseWebLogin\n    foreach($topNav in $topNavs) {\n        if ($TopNav.Url) {\n            $navUrl = $topNav.Url\n            $navTitle = $topNav.Title\n            Add - PnPNavigationNode - Location TopNavigationBar - Title $navTitle - Url $navUrl\n        }\n    }\n}\nCopy - NavigationToplink - SourceHubsiteUrl $sourceHubsiteUrl - DestinationHubsiteUrl $destinationHubsiteUrl<\/code><\/pre>\n\n\n\n<p>JavaScript<\/p>\n\n\n\n<p><strong>Source site image<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/csharpcorner-mindcrackerinc.netdna-ssl.com\/UploadFile\/BlogImages\/08022021074716AM\/bis1.png\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Destination site image<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/csharpcorner-mindcrackerinc.netdna-ssl.com\/UploadFile\/BlogImages\/08022021074716AM\/bis2.png\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Copy quick launch Navigation<\/h2>\n\n\n\n<p>Follow the below code to copy the quick launch from one site to another site.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$srcsiteUrl = Read - Host \"Enter sorce site url\"\n$destSiteUrl = Read - Host \"Enter destination site url\"\n$credential = Get - Credential\n#connect source site url\nConnect - PnPOnline - Url $srcsiteUrl - Credentials $credential\n$TopNavs = Get - PnPNavigationNode - Location QuickLaunch | Select Title, Url\n#connect destination site url\nConnect - PnPOnline - Url $destSiteUrl - Credentials $credential\nforeach($TopNav in $TopNavs) {\n    if ($TopNav.Url) {\n        Add - PnPNavigationNode - Location QuickLaunch - Title $TopNav.Title\n    }\n}<\/code><\/pre>\n\n\n\n<p>JavaScript<\/p>\n\n\n\n<p><strong>Source Site Image<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/csharpcorner-mindcrackerinc.netdna-ssl.com\/UploadFile\/BlogImages\/08022021074716AM\/bis3.png\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Destination site image<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/csharpcorner-mindcrackerinc.netdna-ssl.com\/UploadFile\/BlogImages\/08022021074716AM\/bis4.png\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[221],"tags":[],"class_list":["post-6872","post","type-post","status-publish","format-standard","hentry","category-powershell"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Copy Navigation Using PowerShell - Softree Technology<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/softreetechnology.com\/blog\/powershell\/copy-navigation-using-powershell\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Copy Navigation Using PowerShell - Softree Technology\" \/>\n<meta property=\"og:description\" content=\"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 [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/softreetechnology.com\/blog\/powershell\/copy-navigation-using-powershell\/\" \/>\n<meta property=\"og:site_name\" content=\"Softree Technology\" \/>\n<meta property=\"article:published_time\" content=\"2021-08-03T07:58:33+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-08-03T07:58:35+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/csharpcorner-mindcrackerinc.netdna-ssl.com\/UploadFile\/BlogImages\/08022021074716AM\/bis1.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Copy Navigation Using PowerShell - Softree Technology","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/softreetechnology.com\/blog\/powershell\/copy-navigation-using-powershell\/","og_locale":"en_US","og_type":"article","og_title":"Copy Navigation Using PowerShell - Softree Technology","og_description":"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 [&hellip;]","og_url":"https:\/\/softreetechnology.com\/blog\/powershell\/copy-navigation-using-powershell\/","og_site_name":"Softree Technology","article_published_time":"2021-08-03T07:58:33+00:00","article_modified_time":"2021-08-03T07:58:35+00:00","og_image":[{"url":"https:\/\/csharpcorner-mindcrackerinc.netdna-ssl.com\/UploadFile\/BlogImages\/08022021074716AM\/bis1.png","type":"","width":"","height":""}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/softreetechnology.com\/blog\/powershell\/copy-navigation-using-powershell\/#article","isPartOf":{"@id":"https:\/\/softreetechnology.com\/blog\/powershell\/copy-navigation-using-powershell\/"},"author":{"name":"admin","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/98740297642f06debccdcee2de84086b"},"headline":"Copy Navigation Using PowerShell","datePublished":"2021-08-03T07:58:33+00:00","dateModified":"2021-08-03T07:58:35+00:00","mainEntityOfPage":{"@id":"https:\/\/softreetechnology.com\/blog\/powershell\/copy-navigation-using-powershell\/"},"wordCount":295,"commentCount":0,"publisher":{"@id":"https:\/\/softreetechnology.com\/blog\/#organization"},"image":{"@id":"https:\/\/softreetechnology.com\/blog\/powershell\/copy-navigation-using-powershell\/#primaryimage"},"thumbnailUrl":"https:\/\/csharpcorner-mindcrackerinc.netdna-ssl.com\/UploadFile\/BlogImages\/08022021074716AM\/bis1.png","articleSection":["PowerShell"],"inLanguage":"en","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/softreetechnology.com\/blog\/powershell\/copy-navigation-using-powershell\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/softreetechnology.com\/blog\/powershell\/copy-navigation-using-powershell\/","url":"https:\/\/softreetechnology.com\/blog\/powershell\/copy-navigation-using-powershell\/","name":"Copy Navigation Using PowerShell - Softree Technology","isPartOf":{"@id":"https:\/\/softreetechnology.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/softreetechnology.com\/blog\/powershell\/copy-navigation-using-powershell\/#primaryimage"},"image":{"@id":"https:\/\/softreetechnology.com\/blog\/powershell\/copy-navigation-using-powershell\/#primaryimage"},"thumbnailUrl":"https:\/\/csharpcorner-mindcrackerinc.netdna-ssl.com\/UploadFile\/BlogImages\/08022021074716AM\/bis1.png","datePublished":"2021-08-03T07:58:33+00:00","dateModified":"2021-08-03T07:58:35+00:00","breadcrumb":{"@id":"https:\/\/softreetechnology.com\/blog\/powershell\/copy-navigation-using-powershell\/#breadcrumb"},"inLanguage":"en","potentialAction":[{"@type":"ReadAction","target":["https:\/\/softreetechnology.com\/blog\/powershell\/copy-navigation-using-powershell\/"]}]},{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/softreetechnology.com\/blog\/powershell\/copy-navigation-using-powershell\/#primaryimage","url":"https:\/\/csharpcorner-mindcrackerinc.netdna-ssl.com\/UploadFile\/BlogImages\/08022021074716AM\/bis1.png","contentUrl":"https:\/\/csharpcorner-mindcrackerinc.netdna-ssl.com\/UploadFile\/BlogImages\/08022021074716AM\/bis1.png"},{"@type":"BreadcrumbList","@id":"https:\/\/softreetechnology.com\/blog\/powershell\/copy-navigation-using-powershell\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/softreetechnology.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Copy Navigation Using PowerShell"}]},{"@type":"WebSite","@id":"https:\/\/softreetechnology.com\/blog\/#website","url":"https:\/\/softreetechnology.com\/blog\/","name":"Softree Technology","description":"Celebrating 10+ Years in SharePoint Consulting !","publisher":{"@id":"https:\/\/softreetechnology.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/softreetechnology.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en"},{"@type":"Organization","@id":"https:\/\/softreetechnology.com\/blog\/#organization","name":"Softree Technology","url":"https:\/\/softreetechnology.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2023\/03\/cropped-white-logo-soft.png","contentUrl":"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2023\/03\/cropped-white-logo-soft.png","width":844,"height":230,"caption":"Softree Technology"},"image":{"@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/98740297642f06debccdcee2de84086b","name":"admin","image":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6fc78c8a7aa3fb0bf43c3b9a2e3962d7?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6fc78c8a7aa3fb0bf43c3b9a2e3962d7?s=96&d=mm&r=g","caption":"admin"},"sameAs":["https:\/\/softreeconsulting.com"],"url":"https:\/\/softreetechnology.com\/blog\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts\/6872","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/comments?post=6872"}],"version-history":[{"count":1,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts\/6872\/revisions"}],"predecessor-version":[{"id":6873,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts\/6872\/revisions\/6873"}],"wp:attachment":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/media?parent=6872"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/categories?post=6872"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/tags?post=6872"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}