kwizcom banner advertisement

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 is my PowerShell scripts to get and set hyperlink column values:

Get Hyperlink Field Value using PowerShell:
Here is how to get URL value of SharePoint hyperlink field using PowerShell
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Configuration Variables
$SiteURL = "http://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
    }        
}

Update Hyperlink Field value using PowerShell: 
Here is the SharePoint PowerShell to set hyperlink field
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Configuration Variables
$SiteURL = "http://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 = "http://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!"
}
Get/Set Hyperlink Field Values in SharePoint using PowerShell Get/Set Hyperlink Field Values in SharePoint using PowerShell Reviewed by Salaudeen Rajack on November 22, 2015 Rating: 5

3 comments:

  1. Hi,
    This is script is great and works perfectly in the PowerShell. Could you please help me with how to export this Get list data to export in a CSV please?

    Many Thanks,
    Uttkarsh

    ReplyDelete
  2. Thanks for sharing the link to your blog.

    Cheers,
    Uttkarsh

    ReplyDelete

Please Login and comment to get your questions answered!

Powered by Blogger.