Trying to do a simple loop to populate an array
[array]$td= @()
[int]$test = 4
[int]$x = 0
for($x=1,$x -le $test, $x++)
{
$Temp = (Get-date).AddDays(-$x)
$td += Get-Date $Temp -Format dd/MM/yyyy
}
$td
Error message is due to type casting.. yet I am setting what I want them to be and also seem to be getting a spurious 0?
Error is
7 | for($x=1,$x -le $test, $x++)Line |
| ~~~~~~~~~~~~~~~~~~~~~~~
| Could not compare "1" to "4 0". Error: "Cannot convert the "System.Object[]" value of type "System.Object[]" to type "System.Int32"."