PowerShell 3: Invoke-WebRequest vs Invoke-RestMethod and a SharePoint 2010 list with more than 1000 entries

When using Invoke-RestMethod with a SharePoint 2010 list and ListData.svc, it returns an “System.Xml.XmlElement#http://www.w3.org/2005/Atom#entry” object. Not sure why, but the end result is that you can’t get access to the “rel=next” url, or am I doing something wrong?

$Results=Invoke-RestMethod -uri $ListUrl -UseDefaultCredentials
$Results | gm 
TypeName: System.Xml.XmlElement#http://www.w3.org/2005/Atom#entry

I had to use Invoke-WebRequest and then take the Content and put it in an XML variable, only then could I get to the next page of items.

$MailingLabels = Invoke-WebRequest -Uri $ListUrl -UseDefaultCredentials
$Next =  ($MailingLabelsXML.feed.link | ?{$_.rel -eq "next"}).href

Thoughts?

,

Comments are closed.