I am trying to fix default URL for Hyperlink column in share point list and getting an error. Please help to find the problem.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Configuration Variables
$SiteURL = "http://sharepoint-test/sites/name/"
$ListName = "Test list"
$FieldName= "default"
#Get the Web, List Objects
$web = Get-SPWeb $SiteURL
$List = $Web.Lists.TryGetList($ListName)
If($list)
{
#sharepoint powershell update hyperlink field
$Hyperlink = New-Object Microsoft.SharePoint.SPFieldURLValue
$Hyperlink.Description = "Profile Picture"
$Hyperlink.URL = "http://sharepoint-test/image/profile.jpg"
#Add new List Item
$Item = $List.AddItem()
$Item[$FieldName] = $default
$Item.Update();
Write-host "New Item Added Successfully!"
}
Code returns following error:
Exception calling "Update" with "0" argument(s): "Invalid number value. A number field contains invalid data. Please check the value and try again."
At C:\Users\testuser\Code\test.ps1:22 char:5 + $Item.Update(); + ~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : SPException