SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

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 got a custom Sharepoint list which has the following list items

Hostname  -   IP   -     OS     -    CPUs - RAM -    Disk

Server   Server 2003     3      8    Disk C: 20gb

If i then change, lets say, the RAM so there is now 12gb (or CPU or any of the other values) i would like it to update it)

I got scripts that pull all the information from the servers via WMI and exporting it to a .csv

The csv layout looks like the following

IP,Hostname,OS,CPU,Ram,Disk,Server,Server 2003,3,12,Disk C: 20gb

Now here's the real question, i got a script that add's the items to the list, but if i run it again it adds the item to the list so its now there twice, (one with the old value and one with the new) but i need a script that can update the diffrent column values if they should change, without having to remove the item and add it again with the new values.

share|improve this question

migrated from Dec 18 '11 at 13:34

This question came from our site for professional and enthusiast programmers.

You need to fire an update operation. However you should have an ID or something that helps you in uniquely identifying your record. – Nitin Rastogi Dec 8 '11 at 17:52
up vote 7 down vote accepted

Update list item using powershell -

$SPAssignment = Start-SPAssignment
$SPWeb = Get-SPWeb http://SP -AssignmentCollection $spAssignment

Next step is to get the list:

$SPList = $SPWeb.Lists["Announcements"]

When we have located the list we can retrieve the item. The quickest way is to use the GetItemByID() method:

$SPItem = $SPList.GetItemById("1")

The example above requires that you know the ID of the item. If you don’t know the items ID you can use the Where-Object cmdlet instead:

$SPItem = $SPList.Items | Where { $_["Title"] -eq "New Announcement" }

When you’ve retrieved the item you can modify the item information.

$SPItem[“Title”] = "MyTitle"
$SPItem[“Body”] = "MyBody"

After modifying an item you have to call the Update() method to set the changes.


When you’re done, use the Stop-SPAssignment cmdlet to dispose the SPWeb object.

Stop-SPAssignment $SPAssignment

Source and more info here:

share|improve this answer
feel free to ask if you have questions regarding the example – CodingSheep Dec 8 '11 at 15:44
Thanks alot for the explanation of all the steps – Casper Dec 9 '11 at 8:53

Your Answer


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.