PowerShell scripts can now return their data in pages, so scripts that work with large datasets can spread the work over several runs instead of hitting time or size limits.
How it works
Your script reads the current position from
$paging.context
, which is empty on the first run. To ask for another page, set $paging.next
. SquaredUp passes that value back on the next run and keeps going until a run doesn't set it. All the pages are then combined into a single result for your tile.$offset = if ($paging.context) { $paging.context.offset } else { 0 }
$all = 1..25 | ForEach-Object { @{ id = $_ } }
$all | Select-Object -Skip $offset -First 10
if ($offset + 10 -lt $all.Count) { $paging.next = @{ offset = $offset + 10 } }
Paging works with both data PowerShell Cloud and PowerShell On-Prem. For On-Prem scripts, add a paging parameter (for example
param($paging))
to turn it on.- Learn more about PowerShell Cloud
- Learn more about PowerShell On-Prem