SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to delete some list items and recreate them using a csv file. I can see if I delete the items and then recreate, Sharepoint adds it's own auto icrement int. what if I want a set of fixed values say only 1... 100 for 100 rows. Should the PS script work

$csv = Import-Csv $csvPath

# delete all the current rows - later this may be changed to update current)
Delete-SPListItems $siteUrl $listTitle

 #traverse each row 
foreach ($row in $csv)

    # now lets construct the new row we adding oops you must use the static names not the damnn names on the spreasheet.
    $newItem = $list.Items.Add();

    $newItem["ID"] =  [System.Convert]::ToInt32($row.Id) ;
share|improve this question
no you can't and you shouldn't. the right question would be why would you need to do it at all? i.e. if you have some external system and you want to get IDs from there, just make it a separate field or use document ID, or whatever - but SharePoint ID is internal field and in 99% of cases you don't want to touch it and even if you will find a way - this will most likely just lead to some other issues with your list. thus it would be great if you updated the question explaining what you really want to achieve. – Andrey Markeev Feb 13 '13 at 9:41
Hmmm I understand what you are saying re an internal field. Ok I want my numeric id field to come from my csv file .. Now if I wanted to my uers to be able to store their favourite list items then this is when I want to cross reference the fav list against items with the aforementioned id. Since you have said I can't I will have to add another field to my list def and corresponding col in my csv file. – westerdaled Feb 13 '13 at 9:48
It might work if you copy it to a new list... – Mike Feb 13 '13 at 15:12

Your Answer


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

Browse other questions tagged or ask your own question.