Someone on the PowerShell usenet group asked if it was possible to interact with SharePoint lists through our favourite little shell. Marco Shaw responded and put the pressure on by saying this was my bag of tricks. Who am I to say otherwise? so lets take a look at the recipe:
$service = .\get-webservice2.ps1 http://sharepoint/_vti_bin/lists.asmx
later, if you want to work with a different site, change the Url property like this:
$service.Url = "http://sharepoint/sites/root/subsite/_vti_bin/lists.asmx"
Ok, now we're ready to try the different operations: New, Update and Delete.
PS C:\> $item = @{Title = "Oisin"; Body="Hello, Word."} PS C:\> $result = .\invoke-listoperation.ps1 $service new announcements $item Success. PS C:\> $result.row.ows_ID 2
PS C:\> $item.ID = 2 PS C:\> $item.Body = "Hello, World." PS C:\> $result = .\invoke-listoperation.ps1 $service update announcements $item Success.
PS C:\> $result = .\invoke-listoperation.ps1 $service delete announcements $item Success.
PS C:\> $result = .\invoke-listoperation.ps1 $service delete announcements @{ID=2} Success.
Here's the invoke-listoperation.ps1 script. Just copy and paste it into notepad, save it and away you go!
Page rendered at Thursday, July 03, 2008 6:45:39 PM (Eastern Standard Time, UTC-05:00)
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.