Have a simple array of serial numbers, $arySerials. I use them to make a web services call. The web service API only accepts 50 serial numbers at a time. So, I want to send 50 from $arySerials, then remove those 50 from the original array with the working array $arySerialsWorking. Without iterating through a ForEach.
while ($arySerialNumbers.count -ne 0)
{
$arySerialsWorking = $arySerialNumbers[0..49]
$strSerialsWorkingOut = $arySerialsWorking -join ","
$objOutContractInformationArray += Get-ASContractInformation -arySerialNumbers $strSerialsWorkingOut
$arySerialNumbers = $arySerialNumbers | where {$_ -ne $arySerialsWorking }
}
I want:
$arySerialNumbers = $arySerialNumbers | where {$_ -ne $arySerialsWorking }
To remove the already used serial numbers. Until eventually $arySerialNumbers.count will end up at 0. I want to do this without doing a long ForEach Itteration.
[system.collections.arraylist]. You could alternatively use a for loop and increment your index by 50 on each end of the range for each iteration.