I need some help with a problem I am working on.
I have an array of objects called $Jobs. $Jobs has several noteproperties of which the important ones are fsono, fduedate, fcompany.
What I want to do is copy only the items that are late into a new array of objects called $late. I have tried everything that I can think of.
I have tried
$late = new-object System.Object[] $countLate#number of late jobs
for($i = 0; $i -lt $Jobs.Length; $i++)
{
if($job[$i].fduedate -le $currentDate)
{
$late[$x] = $Jobs[$i]
$x++
}
}
But that does not give me anything in $late when I do PS>$late[0].fsono
The only work around I have found is to clone it
$late = $Jobs.clone()
And then over write the contents of the $late array doing something like
for($i = 0; $i -lt $Jobs.Length; $i++)
{
if($job[$i].fduedate -le $currentDate)
{
$late[$x] = $Jobs[$i]
$x++
}
}
Which I hate...
Any ideas? Has to be something easy that I am just unable to see due to being fixated on the problem.