Puts pipeline items into one or more batches
Create-Batch
[[-Size] <ulong>]
[-InputObject] <Object>
[<CommonParameters>]This cmdlet puts the items in the pipeline into batches of a sertain ammount.
This example sents batches of 3 items down the PowerShell pipeline.
0..9 |Create-Batch -Size 3 |ForEach-Object { "$_" }
0 1 2
3 4 5
6 7 8
9This example removes the batches of 3 items and creates new batches of 4 items.
0..9 |Create-Batch -Size 3 |Create-Batch |Create-Batch -Size 4 |ForEach-Object { "$_" }
0 1 2 3
4 5 6 7
8 9This creates a single batch (array) containing all the itams
The result of this statement is the same as: Get-Process |Set-Content .\Process.txt
But note that this appears (for yet unknown reason) about twice as fast.
See: PowerShell issue #18070
Get-Process |Create-Batch |Set-Content .\Process.txtThe size of the batches (arrays) to be created.
If the -Size parameter is omitted (or 0) all current batches will be removed.
Note that only the top arrays (batches) will be flattened.
| Type: | UInt64 |
| Position: | 0 |
| Default value: | [UInt64]::MaxValue |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
The list of items to be put into batches (arrays)
| Type: | Object |
| Position: | 1 |
| Default value: | |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
A list of items
One or more arrays (Object[]) contain the input items
- 1: #18070