Búsqueda de sitios web

SharePoint Online: agregar un enlace de navegación superior mediante PowerShell


Requisito: Agregue un vínculo a la navegación superior en SharePoint Online mediante PowerShell.

¿Cómo agregar un vínculo en la barra de navegación superior en SharePoint Online?

Al crear o personalizar un sitio de SharePoint Online, es posible que necesite agregar un vínculo a la navegación superior. Esta publicación de blog le mostrará cómo agregar un vínculo en la barra de navegación superior en SharePoint Online. También le mostraremos cómo usar PowerShell para agregar un vínculo en la barra de navegación superior de su sitio de SharePoint.

En los sitios modernos de comunicación y equipos, ofrece una interfaz sencilla para agregar enlaces al menú superior. Para agregar un nuevo vínculo a la navegación superior en SharePoint Online, siga los pasos a continuación:

  1. Navegue a su sitio moderno de SharePoint Online y haga clic en el enlace "Editar" al final del menú.

  2. Pase el cursor sobre el panel de navegación Editar hasta que vea aparecer un signo +.
  3. Haga clic en el signo + para agregar un nuevo enlace.
  4. Ingrese la URL y muestre el nombre del nuevo enlace en los campos correspondientes.

  5. Haga clic en "Guardar" para agregar el nuevo enlace a la barra de navegación superior.

¡Eso es todo! El nuevo vínculo debería aparecer ahora en la barra de navegación superior de su sitio moderno de SharePoint Online.

Agregar un vínculo a la navegación superior en sitios clásicos

  1. Inicie sesión en su sitio de SharePoint Online como administrador o usuario con control total.
  2. Haga clic en el engranaje de Configuración >> Configuración del sitio
  3. Haga clic en el enlace "Barra de enlaces superior" debajo del grupo "Apariencia y sensación".
  4. Ahora puede agregar un nuevo enlace a la barra de navegación superior ingresando el nombre del nuevo enlace y la URL.

Si la plantilla de su sitio es un sitio de publicación (¡o un sitio con una función de publicación habilitada!), obtendrá un enlace de "Navegación" en la configuración del sitio. Puede agregar enlaces en "Navegación global".

¿Cómo agregar la barra de navegación superior en SharePoint Online?
En los sitios de grupo modernos, puede mover el menú de navegación izquierdo a la navegación superior. Cambie el inicio rápido a navegación superior en SharePoint Online

PowerShell para agregar un vínculo a la navegación superior en SharePoint Online:

Aquí está el PowerShell para agregar un enlace a la navegación global del sitio de SharePoint Online.


#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

#Add new Link in Top Navigation
Function Add-SPOTopNavigationLink()
{
    Param(
        [String]$SiteURL,
        [parameter(Mandatory=$false)][String]$ParentNodeTitle,
        [String]$Title,
        [String]$URL
    )

    #Setup Credentials to connect
    $Cred= Get-Credential
    $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)

    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = $Credentials

    #Get the Top Navigation of the web
    $TopNavigationBar = $Ctx.Web.Navigation.TopNavigationBar
    $Ctx.load($TopNavigationBar)
    $Ctx.ExecuteQuery()

    #Populate New node data
    $NavigationNode = New-Object Microsoft.SharePoint.Client.NavigationNodeCreationInformation 
    $NavigationNode.Title = $Title
    $NavigationNode.Url = $URL
    $NavigationNode.AsLastNode = $true

    #Get the Parent Node
    $ParentNode = $TopNavigationBar | Where-Object {$_.Title -eq $ParentNodeTitle}
    
    #Add New node to the navigation
    If($ParentNode -eq $null)
    {
        #Check if the Link with Title exists already
        $Node = $TopNavigationBar | Where-Object {$_.Title -eq $Title}
        If($Node -eq $Null)
        { 
            #Add Link to Root node of the Navigation
            $Ctx.Load($TopNavigationBar.Add($NavigationNode))
            $Ctx.ExecuteQuery()
            Write-Host -f Green "New Link '$Title' Added to the Navigation Root!"
        }
        Else
        {
            Write-Host -f Yellow "Navigation Link '$Title' Already Exists in Root!"
        }
    }
    else
    {
        #Get the Parent Node
        $Ctx.Load($ParentNode)
        $Ctx.Load($ParentNode.Children)
        $Ctx.ExecuteQuery()
 
        #Check if the Link with given title exists
        $Node = $ParentNode.Children | Where-Object {$_.Title -eq $Title}
        If($Node -eq $Null)
        { 
            #Add Link to Parent Node
            $Ctx.Load($ParentNode.Children.Add($NavigationNode))
            $Ctx.ExecuteQuery()
            Write-Host -f Green "New Navigation Link '$Title' Added to the Parent '$ParentNodeTitle'!"
        }
        Else
        {
            Write-Host -f Yellow "Navigation Link '$Title' Already Exists in Parnet Node '$ParentNodeTitle'!"
        }
    }
}
 
#Config Parameters
$SiteURL="https://Crescent.sharepoint.com/unitedstates"

#Call the function to Add a New Link in Root of the navigation
Add-SPOTopNavigationLink -SiteURL $SiteURL -Title "Support Center" -URL "https://support.crescent.com"

#Call the function to Add a link in "Support Center" node of the navigation
Add-SPOTopNavigationLink -SiteURL $SiteURL -ParentNodeTitle "Support Center" -Title "Application Support" -URL "https://suppport.crescent.com/apps"

Resultado del guión:

SharePoint Online: PnP PowerShell para agregar un vínculo en la barra de menú de navegación global

Utilice el cmdlet Add-PnPNavigationNode de PnP PowerShell para agregar un vínculo a la navegación superior o al inicio rápido en SharePoint Online:


#Config Variables
$SiteURL = "https://Crescent.sharepoint.com"

#Get Credentials to connect
$Cred = Get-Credential

Try {
    #Connect to PnP Online
    Connect-PnPOnline -Url $SiteURL -Credentials $Cred
    
    #Add a Link to Top Navigation Bar
    Add-PnPNavigationNode -Title "Support Center" -Url "https://support.crescent.com" -Location TopNavigationBar

    #Get the Navigation node "Support Center"
    $ParentID = Get-PnPNavigationNode -Location TopNavigationBar | Where {$_.Title -eq "Support Center"}  | Select -ExpandProperty ID
    #Add a link under "Support Center
    Add-PnPNavigationNode -Title "Application Support" -Url "https://support.crescent.com/apps" -Location TopNavigationBar -Parent $ParentID
 
    Write-host "Quick Launch Links Added Successfully!" -f Green
}
catch {
    write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}

Artículos relacionados