0

I have a csv file with ID, Region and Phone number. I need to run a powershell to update all the items that has ID match to update Region and Phone Number. I have following and not sure if this is going to do it. I am starting with write-host and it shows blank. Any idea

$SiteUrl = "http://inside.power.gov"
$web = Get-SPWeb $SiteUrl
$ListName = "Survey List"
$List = $web.Lists[$ListName]

$csv = import-csv "c:\updateddata.csv"

foreach($item in $csv)
{
    $spItems = $List.GetItemById($item.ID)
    write-host $item.Region
    write-host $item.Phone Number
    write-host $spItems.Region Name

    #$spItems["Region Name"] = $item.Region
    #$spItems["Phone Number"] = $item.Phone Number
    #$spItems.SystemUpdate()
}

$web.Dispose()
1
  • I updated the code and now it's working.
    – Todd Bayne
    Feb 4, 2016 at 16:58

1 Answer 1

1

Answer was discovered by user:

$SiteUrl = "http://inside.power.gov"
$web = Get-SPWeb $SiteUrl
$ListName = "Survey List"
$List = $web.Lists[$ListName]

$csv = import-csv "c:\updateddata.csv"

foreach($item in $csv)
{
    $spItems = $List.GetItemById($item.ID)
    write-host $item.Region
    write-host $item."Phone Number"
    write-host $spItems["Region Name"]

    #$spItems["Region Name"] = $item.Region
    #$spItems["Phone Number"] = $item.Phone Number
    #$spItems.SystemUpdate()
}

$web.Dispose()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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