Skip to content

Instantly share code, notes, and snippets.

@pmatthews05
Last active April 6, 2021 16:14
Show Gist options
  • Save pmatthews05/b741485a169b645433c1676215fe0485 to your computer and use it in GitHub Desktop.
Save pmatthews05/b741485a169b645433c1676215fe0485 to your computer and use it in GitHub Desktop.
function Get-ListDataAsStream {
param (
[Parameter(Mandatory)]
[string]
$SiteUrl,
[Parameter(Mandatory)]
[string]
$ListName,
[Parameter(Mandatory)]
[string]
$CAMLQuery,
[Parameter(Mandatory = $false)]
[string]
$NextLink
)
$QueryUrl = "$SiteUrl/_api/web/lists/GetbyTitle('$ListName')/RenderListDataAsStream"
Write-Information -MessageData:"QueryUrl:$QueryUrl"
if ($NextLink -and $NextLink.StartsWith('?')) {
$NextLink = $NextLink.Substring(1)
Write-Information -MessageData:"Paging:$NextLink"
}
$body = @{
parameters = @{
Paging = $NextLink
RenderOptions = 2
ViewXml = $CAMLQuery
}
}
return Invoke-PnPSPRestMethod -Url:"$QueryUrl" -Method:Post -ContentType:"application/json;odata=nometadata" -Content:$body
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment