butler_alfred
butler_alfred

Reputation: 83

Updating a Sharepoint List from Powershell

I can modify a new datarow in Powershell but it will not update the Sharepoint List on the site itself.

Here is a bit of my code

Here i fill my dataset with table info

$connString = 'Provider=Microsoft.ACE.OLEDB.12.0;WSS;IMEX=2;RetrieveIds=Yes;DATABASE=https://sharepoint/;LIST={6d552622-3333-4444-9999-234d32d32d3};'
$spConn = new-object System.Data.OleDb.OleDbConnection($connString)
$spConn.open()
$qry="select * from myList"
$cmd = new-object System.Data.OleDb.OleDbCommand($qry,$spConn)
$da = new-object System.Data.OleDb.OleDbDataAdapter($cmd)
$dataSet = new-object System.Data.DataSet
$sp = $dataSet.Tables.Add("Table")
$da.fill($sp)

Here i add a new datarow

 $row = $sp.NewRow()
 $sp.Rows.Add($row)
 $row["Title"] = "Foo"

And here i try to update the Sharepoint List

 $da.Update($sp)

It does not let me update, any help or guidence would be great.

Thanks

Upvotes: 1

Views: 1228

Answers (1)

Chad Miller
Chad Miller

Reputation: 41847

You are adding a new row which is an insert. Inserts are not supported by the OleDB provider against a SharePoint list. You can select or update the value of an existing row, but not create a new row.

Upvotes: 1

Related Questions