I can’t figure out why I’m getting this error after I iterate through my For Each loop after a period of time.
ERROR:
Cannot convert value “2147483648” to type “System.Int32”. Error: “Value was either too large or too small for an Int32.”
At line:120 char:9
-
$n = $n + $n
-
~~~~~~~~~~~~
- CategoryInfo : MetadataError: ( , ArgumentTransformationMetadataException
- FullyQualifiedErrorId : RuntimeException
…
[int]$n = 1
$rowObjects = @()
ForEach ($row in $rowData) {
If ($($row.GetType().Name.ToString()) -eq “DataRow”) {
$rd = @{RowCount=$n;
Column1=$row.Column1;}
$rowObject = New-Object -TypeName PSObject -Property $rd
$rowObjects += $rowObject
$n = $n + $n
}
}
$rowObjects | ConvertTo-HTML -head $a -Body $b | Out-File d:\Test.htm