Copy-SPOHubSiteNavigation.ps1
<#PSScriptInfo .VERSION 1.3 .GUID b8fc87fb-cb67-4968-977f-9b9d710ac21f .AUTHOR NarasimaPerumal Chandramohan .COMPANYNAME JiJi Technologies Private Limited .COPYRIGHT All Right Reserved (c) JiJi Technologies Private Limited .TAGS SPO Hubsites TopNavigation PowerShell .LICENSEURI .PROJECTURI .ICONURI .EXTERNALMODULEDEPENDENCIES SharePointPnPPowerShellOnline .REQUIREDSCRIPTS .EXTERNALSCRIPTDEPENDENCIES .RELEASENOTES #> <# .DESCRIPTION Using this script, you can copy the SharePoint Online Hub Site top navigation between sites. .PARAMETER SourceHubsiteUrl Enter the Source SPO Hub site Url .PARAMETER DestinationHubsiteUrl Enter the Destination SPO Hub site Url .EXAMPLE Copy-SPOHubSiteNavigation.ps1 -SourceHubsiteUrl https://tenantname.sharepoint.com/sites/sourceHubsite -DestinationHubsiteUrl https://tenantname.sharepoint.com/sites/destHubsite #> 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 } #Get Top Navigation from the given Hub Site Function Get-NavigationToplink($Hubsite,$Credentials) { [System.Windows.MessageBox]::Show("Provide the login credentials for ($Hubsite) Site") Connect-PnPOnline -Url $Hubsite -UseWebLogin $TopNavs=Get-PnPNavigationNode -Location TopNavigationBar |Select Title,Url Disconnect-PnPOnline return $TopNavs } #Add the Top Navigation to the given Hub Site Function Add-NavigationToplink($TopNavs,$Hubsite) { [System.Windows.MessageBox]::Show("Provide the login credentials for ($Hubsite) Site") Connect-PnPOnline -Url $Hubsite -UseWebLogin foreach($TopNav in $TopNavs) { if($TopNav.Url) { Add-PnPNavigationNode -Location TopNavigationBar -Title $TopNav.Title -Url $TopNav.Url } } } Copy-NavigationToplink -SourceHubsiteUrl $SourceHubsiteUrl -DestinationHubsiteUrl $DestinationHubsiteUrl # SIG # Begin signature block # MIIVHwYJKoZIhvcNAQcCoIIVEDCCFQwCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUq1YXVJmr/JNBbiJVu3wULYED # IHmgghAPMIIEmTCCA4GgAwIBAgIPFojwOSVeY45pFDkH5jMLMA0GCSqGSIb3DQEB # BQUAMIGVMQswCQYDVQQGEwJVUzELMAkGA1UECBMCVVQxFzAVBgNVBAcTDlNhbHQg # TGFrZSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxITAfBgNV # BAsTGGh0dHA6Ly93d3cudXNlcnRydXN0LmNvbTEdMBsGA1UEAxMUVVROLVVTRVJG # aXJzdC1PYmplY3QwHhcNMTUxMjMxMDAwMDAwWhcNMTkwNzA5MTg0MDM2WjCBhDEL # MAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UE # BxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKjAoBgNVBAMT # IUNPTU9ETyBTSEEtMSBUaW1lIFN0YW1waW5nIFNpZ25lcjCCASIwDQYJKoZIhvcN # AQEBBQADggEPADCCAQoCggEBAOnpPd/XNwjJHjiyUlNCbSLxscQGBGue/YJ0UEN9 # xqC7H075AnEmse9D2IOMSPznD5d6muuc3qajDjscRBh1jnilF2n+SRik4rtcTv6O # KlR6UPDV9syR55l51955lNeWM/4Og74iv2MWLKPdKBuvPavql9LxvwQQ5z1IRf0f # aGXBf1mZacAiMQxibq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