ค้นหาเว็บไซต์

เพิ่มรายการใหม่ในรายการลิงก์ใน SharePoint โดยใช้ PowerShell


คุณกำลังมองหาวิธีที่รวดเร็วในการเพิ่มรายการใหม่ลงในรายการลิงก์ SharePoint โดยใช้ PowerShell หรือไม่? ฉันจะแสดงวิธีใช้ PowerShell เพื่อสร้างรายการใหม่ใน SharePoint:

นี่คือสคริปต์ PowerShell เพื่อเพิ่มรายการใหม่ลงในรายการลิงก์ SharePoint:


Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Custom Function to add new item to SharePoint link list
Function Add-LinkListItem($WebURL, $ListName, $LinkURL, $LinkTitle)
{
    try
    {
        $ErrorActionPreference ="Stop" 

        #Get the Web
        $Web = Get-SPWeb $WebURL

        #Get the link list
        $List = $web.lists[$ListName]
        
        #Create a new item
        $NewItem = $list.Items.Add()
 
        #Add properties to this list item
        $NewItem["URL"] = "$($LinkURL), $($LinkTitle)"

        #Update the object so it gets saved to the list
        $NewItem.Update()
        
        write-host "New Item has been Added to the List!"-foregroundcolor Green
    }
    catch [System.SystemException]
    {
        write-host "New Item Creation failed due to:" $_.Exception.Message -foregroundcolor Red
    }
    finally
    {
        #Dispose web object
        $web.Dispose()
        $ErrorActionPreference ="Continue" 
    }
}

#Call the function to Add new list item
Add-LinkListItem "https://sharepoint.crescent.com/" "Quick Links" "https://intranet.crescent.com" "Crescent Intranet"

และผลลัพธ์:

บทความที่เกี่ยวข้อง