Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am running a powershell to import csv into a list. There is one field "ProviderURL" in the list. In the csv I had http://www.contoso.com and it imported fine. Howerver, I would like it to be Contoso as Description and http://www.contoso.com as a link.

How would I format my csv so that powershell will add providerURL in this fashion?

btw, here is the ps script

$spWeb = Get-SPWeb http://portal.company.com/site1
$spList = $spWeb.lists["TestList"]
$csvFile = "c:\\import.csv"
foreach($item in Import-CSV $csvFile)
{
    $newItem = $spList.Items.Add()
    $newItem["Title"] = $item.Title
    $newItem["ProviderURL"] = $item.ProviderURL
    $newItem.Update()
}
share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

Here is how to approach your issue.

  1. Make sure your csv have an additional column for url description. Let's call that "urlDescription"
  2. Now add following to your PS script.

    $field = New-Object Microsoft.SharePoint.SPFieldURLValue

    $field.Description = $item.urlDescription

    $field.URL = $item.ProviderURL

    $newItem["ProviderURL"] = $field

I hope this helps.

share|improve this answer
    
It worked like charm. THIS IS FIRST TIME I GOT A QUICK RESPOND. I FEEL LIKE THIS SITE IS DEAD AS I HARDLY GET ANY REPLY. THANKS Monica for your help. –  Laura Burkis Apr 4 '12 at 16:20
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.