Geeks With Blogs
SharePoint Wiki! Sharing is gaining...
If you are trying to update a hyperlink/url type of column of a SharePoint list item using PowerShell and are getting the exception:
Unable to index into an object of type Microsoft.SharePoint.SPListItem.
At C:\mypowershell.ps1:39 char:10
+       $item[ <<<< "Website"] = $itemUrl      
    + CategoryInfo          : InvalidOperation: (RW_Website:String) [], RuntimeException
    + FullyQualifiedErrorId : CannotIndex

Then look no further :)

The url is basically stored like a simple string with url, description divided by comma.

So all you need to do is:

$myUrl = "http://www.google.com, Google"
$listitem["Link"] = $myUrl

That will, assuming "Link" is a type of "Hyperlink or Picture" (Hyperlink), create a link that says Google and links to http://www.google.com.

Also make sure you don't miss out on the 'http://' part as without that the value will not pass the SharePoint validation of allowed values.
Posted on Tuesday, July 10, 2012 10:36 AM | Back to top


Comments on this post: Modify “Link”/ "HyperLink"/URL field using Powershell

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © KunaalKapoor | Powered by: GeeksWithBlogs.net