Get/Set Hyperlink Field Values in SharePoint using PowerShell

Requirement:  PowerShell to get and update hyperlink URL field value in SharePoint

sharepoint powershell get update hyperlink url field value

Here are my PowerShell scripts to get and set hyperlink column values:

Here is how to get the URL value of the SharePoint hyperlink field using PowerShell:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Configuration Variables
$SiteURL = "https://intranet.crescent.com/"
$ListName = "UserProfiles"
$FieldName="Picture"

#Get the Web, List Objects
$web = Get-SPWeb $SiteURL
$List = $Web.Lists.TryGetList($ListName)

If($list)
{
    foreach($Item in $List.Items)
    {
        #Get the Hyperlink column
        $Picture = New-Object Microsoft.SharePoint.SPFieldUrlValue($Item[$FieldName])
        #Get the URL of the Hyperlink
        $Picture.URL
        #Get the Decription - Title
        $Picture.Description
    }        
}

Here is the SharePoint PowerShell to set the hyperlink field.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Configuration Variables
$SiteURL = "https://intranet.crescent.com/"
$ListName = "UserProfiles"
$FieldName="Picture"

#Get the Web, List Objects
$web = Get-SPWeb $SiteURL
$List = $Web.Lists.TryGetList($ListName)

If($list)
{
    #sharepoint powershell update hyperlink field
    $Picture = New-Object Microsoft.SharePoint.SPFieldURLValue
    $Picture.Description = "Profile Picture"
    $Picture.URL = "https://intranet.crescent.com/UserProfiles/Images/profile.jpg"
    
    #Add new List Item
    $Item = $List.AddItem()
    $Item[$FieldName] = $Picture
    $Item.Update()  
    
    Write-host "New Item Added Successfully!"
}

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

5 thoughts on “Get/Set Hyperlink Field Values in SharePoint using PowerShell

Leave a Reply

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