Skip to content

Instantly share code, notes, and snippets.

@star-crossed
Created March 31, 2017 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save star-crossed/81a9c55af95b02bf6f25b5a1b2e326d0 to your computer and use it in GitHub Desktop.
Save star-crossed/81a9c55af95b02bf6f25b5a1b2e326d0 to your computer and use it in GitHub Desktop.
Example of adding row number and grouping by 200 to allow batches for CSOM's ExecuteQuery
$csv | ForEach-Object {
Add-Member -InputObject $_ -MemberType NoteProperty -Name 'Row' -Value ([int]($csv.IndexOf($_) / 200))
} | Group-Object -Property 'Row' | ForEach-Object {
$_.Group | ForEach-Object {
# Compose your batch
}
$context.ExecuteQuery()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment