Add New Item to Link List in SharePoint using PowerShell

Are you looking for a quick way to add new items to a SharePoint link list using PowerShell? Let me show you how to use PowerShell to create a new list item in SharePoint:

Here is the PowerShell script to add a new item to the SharePoint link list:

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"

And the output:

Add New Item to SharePoint Link list with PowerShell

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

Leave a Reply

Your email address will not be published. Required fields are marked *