1

I got a custom Sharepoint list which has the following list items

Hostname  -   IP   -     OS     -    CPUs - RAM -    Disk

Server      1.1.1.1   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
1.1.1.1,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.

2
  • How about share your script or at least give us the absolute basic info needed to help you out - how are you updating SharePoint? SharePoint OM, Client OM, Web Services, Power shell or something else?
    – Ryan
    Dec 8, 2011 at 15:15
  • I tagged it as Powershell so thats what im using
    – Casper
    Dec 9, 2011 at 11:47

1 Answer 1

1

You need to know the item ID you are updating, supposing you are using powershell (the tag you have put), it is like that: Let's assume your list name is Servers

$site = new-object Microsoft.SharePoint.SPSite(spserver)
$web = $site.OpenWeb()
$spList = $web.Lists["Servers"]
$serverItem = $spList.GetItemByID(1)
$serverItem["RAM"] = 12
$serverItem.Update()

In the GetItemByID methof you must put the correct ID of an item that you wish to update.

If you have your own identifier - let say you know that IPs are unique, you'll need to select item by that field, using CAML query.

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.