SharePoint Online: เพิ่มลิงก์การนำทางยอดนิยมโดยใช้ PowerShell
ความต้องการ: เพิ่มลิงก์ไปยังการนำทางด้านบนสุดใน SharePoint Online โดยใช้ PowerShell
จะเพิ่มลิงก์ในแถบนำทางด้านบนใน SharePoint Online ได้อย่างไร
เมื่อสร้างหรือกำหนดไซต์ SharePoint Online เอง คุณอาจต้องเพิ่มลิงก์ไปยังการนำทางด้านบน โพสต์ในบล็อกนี้จะแสดงวิธีการเพิ่มลิงก์ในแถบนำทางด้านบนสุดใน SharePoint Online นอกจากนี้เรายังจะแสดงวิธีใช้ PowerShell เพื่อเพิ่มลิงก์ในแถบนำทางด้านบนของไซต์ SharePoint ของคุณ
บนไซต์ทีมและการสื่อสารที่ทันสมัย มีอินเทอร์เฟซที่ใช้งานง่ายเพื่อเพิ่มลิงก์ไปยังเมนูด้านบน เมื่อต้องการเพิ่มลิงก์ใหม่ไปยังการนำทางด้านบนสุดใน SharePoint Online ให้ทำตามขั้นตอนด้านล่าง:
ไปที่ไซต์สมัยใหม่ของ SharePoint Online แล้วคลิกลิงก์ "แก้ไข" ที่ท้ายเมนู
- โฮเวอร์เหนือบานหน้าต่างแก้ไขการนำทาง จนกว่าคุณจะเห็นเครื่องหมาย + ปรากฏขึ้น
- คลิกที่เครื่องหมาย + เพื่อเพิ่มลิงค์ใหม่
-
ป้อน URL และแสดงชื่อลิงก์ใหม่ในช่องที่เหมาะสม
- คลิก "บันทึก" เพื่อเพิ่มลิงก์ใหม่ลงในแถบนำทางด้านบน
แค่นั้นแหละ! ลิงก์ใหม่ควรปรากฏในแถบนำทางด้านบนสุดบนไซต์สมัยใหม่ของ SharePoint Online ของคุณ
เพิ่มลิงก์ไปยังการนำทางยอดนิยมในไซต์คลาสสิก
- เข้าสู่ระบบไซต์ SharePoint Online ของคุณในฐานะผู้ดูแลระบบหรือผู้ใช้ที่มีสิทธิ์ควบคุมทั้งหมด
- คลิกที่เกียร์การตั้งค่า >> การตั้งค่าไซต์
- คลิกลิงก์ "แถบลิงก์บนสุด" ใต้กลุ่ม "รูปลักษณ์และความรู้สึก"
ตอนนี้คุณสามารถเพิ่มลิงก์ใหม่ลงในแถบนำทางด้านบนได้โดยการป้อนชื่อของลิงก์ใหม่ และ URL
ถ้าเทมเพลตไซต์ของคุณเป็นไซต์การประกาศ (หรือไซต์ที่เปิดใช้งานฟีเจอร์การประกาศ!) คุณจะได้รับลิงก์ "การนำทาง" ใต้การตั้งค่าไซต์ คุณสามารถเพิ่มลิงก์ใต้ "การนำทางทั่วโลก"
ในไซต์ทีมสมัยใหม่ คุณสามารถย้ายเมนูการนำทางด้านซ้ายไปยังการนำทางด้านบนได้! สลับการเปิดใช้งานด่วนเป็นการนำทางด้านบนใน SharePoint Online
PowerShell เพื่อเพิ่มลิงก์ไปยังการนำทางด้านบนใน SharePoint Online:
นี่คือ PowerShell สำหรับเพิ่มลิงก์ไปยังการนำทางส่วนกลางของไซต์ 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"
ผลลัพธ์ของสคริปต์:
SharePoint Online: PnP PowerShell เพื่อเพิ่มลิงก์ในแถบเมนูการนำทางส่วนกลาง
ใช้ Add-PnPNavigationNode cmdlet จาก PnP PowerShell เพื่อเพิ่มลิงก์ไปยังการนำทางด้านบนหรือเปิดใช้งานด่วนใน 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
}



