Hi,
I am trying to sum the total price within Powershell using the below code
For ($i=0; $i -le $OrderInfo.count; $i++)
{
$totalprice = $totalprice + $Orderinfo[$i]."Item Price" * $Orderinfo[$i]."Item Quantity"
}
However when I am running it I am getting the following error
Specified argument was out of the range of valid values.
Parameter name: times
At D:\Powershell\EDI.ps1:53 char:5
+ $totalprice = $totalprice + $Orderinfo[$i]."Item Price" * $Orderi ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], ArgumentOutOfRangeException
+ FullyQualifiedErrorId : System.ArgumentOutOfRangeException
Example data below. Any help appreciated.
Item Quantity Item Price
1 82
1 12
1 0
1 68
1 0
1 0
6 1
1 -6
-6 1
-1 1
-1 1
-3 1
-1 1
-1 1
-1 1
-1 1
-1 1
-8 0.1
-12 24.55
-6 32.73
-12 29.09
-6 30.91
-6 29.55
-1 18
-6 0.5
-1 18
-6 0.5