SharePoint Online: Add Hyperlink or Picture Column to List using PowerShell

Requirement: Add a hyperlink column to the SharePoint Online list.

The Hyperlink or Picture column in SharePoint Online is used to store URLs of web addresses or pictures. The field type can be configured to hold either a URL or a Picture. Here are the steps to add a hyperlink field to the SharePoint Online list:

  1. Browse to your SharePoint Online site and navigate to the target list in which you want to add a hyperlink or picture column.
  2. Under the List tab, click on the “Create Column” button in the ribbon.
  3. Provide the Name to your new column, specify the type as “Hyperlink or Picture”. Select the format of the URL as either Hyperlink or Picture from the “Format URL as” dropdown. Add Hyperlink or Picture Column to SharePoint Online List using PowerShell
  4. Fill in other optional values such as Field description, Required, and Add to default view settings.  Click on “OK” to create a Hyperlink or Picture field in the SharePoint Online list.

Here is the PowerShell script to add a hyperlink field to the SharePoint Online list. Just set the parameters accordingly and run the script.

#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"

#Custom function to add column to list
Function Add-HyperLinkPictureColumnToList()
        [Parameter(Mandatory=$true)] [string] $SiteURL,
        [Parameter(Mandatory=$true)] [string] $ListName,
        [Parameter(Mandatory=$true)] [string] $Name,
        [Parameter(Mandatory=$true)] [string] $DisplayName,
        [Parameter(Mandatory=$false)] [string] $Description=[string]::Empty,
        [Parameter(Mandatory=$false)] [string] $IsRequired = "FALSE",
        [Parameter(Mandatory=$false)] [string] $Format ="Hyperlink"

    #Generate new GUID for Field ID
    $FieldID = New-Guid

    Try {
        $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 List
        $List = $Ctx.Web.Lists.GetByTitle($ListName)

        #Check if the column exists in list already
        $Fields = $List.Fields
        $NewField = $Fields | where { ($_.Internalname -eq $Name) -or ($_.Title -eq $DisplayName) }
        if($NewField -ne $NULL)  
            Write-host "Column $Name already exists in the List!" -f Yellow
            #Define XML for Field Schema
            $FieldSchema = "<Field Type='URL' ID='{$FieldID}' DisplayName='$DisplayName' Name='$Name' Description='$Description' Required='$IsRequired' Format='$Format' />"
            $NewField = $List.Fields.AddFieldAsXml($FieldSchema,$True,[Microsoft.SharePoint.Client.AddFieldOptions]::AddFieldInternalNameHint)

            Write-host "New Column Added to the List Successfully!" -ForegroundColor Green  
    Catch {
        write-host -f Red "Error Adding Column to List!" $_.Exception.Message

#Set parameter values
$DisplayName="Project Reference"
$Description="Enter the Project Reference"
$Format="Hyperlink" #or "Image"

#Call the function to add column to list
Add-HyperLinkPictureColumnToList -SiteURL $SiteURL -ListName $ListName -Name $Name -DisplayName $DisplayName -Description $Description -Format $Format 

PnP PowerShell to Add URL Column to SharePoint Online List

Use the Add-PnPField cmdlet in PnP PowerShell with type as “URL” to create a hyperlink field in SharePoint online list:

#Config Variables
$SiteURL = ""
$ListName= "Projects"

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)

#Add Hyperlink Field to list
Add-PnPField -Type URL -List $ListName -DisplayName "Company Website" -InternalName "CompanyWebsite" -AddToDefaultView

Similarly, we can create a hyperlink field from the XML schema.

#Define XML Schema for URL Field
$FieldXML= "<Field Type='URL' Name='CompanyWebsite' ID='$([GUID]::NewGuid())' DisplayName='Company Website' Format='Hyperlink' ></Field>"

#Add URL Field to list
Add-PnPFieldFromXml -FieldXml $FieldXML -List $ListName

Set the Format=’Image’ attribute for the Picture field.

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!

2 thoughts on “SharePoint Online: Add Hyperlink or Picture Column to List using PowerShell

  • Hi Salaudeen,

    It shows the option for hyperlink, not browse image. How to browse image through Picture column?
    Could you please help me on this.


    • There is no way to do this out of the box. You have to use Custom/3rd party controls.. E.g.


Leave a Reply

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