I'm running SharePoint 2010 and I have a requirement to be able to query SharePoint from Powershell without having the SharePoint snap-in. I have been experimenting with some code that I found but I'm having trouble filtering the list items. The script below always displays all the items in the output when I'm expecting one item. What's the best way to filter list items?
$url = "https://mysite/market/_vti_bin/listdata.svc/Products?$filter=Title eq 'Movies'" $request = [System.Net.WebRequest]::Create($url) $request.UseDefaultCredentials = $true $request.Accept = ‘application/json;odata=verbose’ $response = $request.GetResponse() $reader = New-Object System.IO.StreamReader $response.GetResponseStream() # ConvertFrom-Json : Cannot convert the Json string because a dictionary converted from it contains duplicated keys ‘Id’ and ‘ID’. $response = $reader.ReadToEnd() #$response = $reader.ReadToEnd() -creplace ‘"ID":’, ‘"DummyId":’ $result = ConvertFrom-Json -InputObject $response $result.d.results | select Id, Title