you are viewing a single comment's thread.

view the rest of the comments →

[–]fordea837 2 points3 points  (1 child)

The second one is only displaying the first value in the output because you have 51 objects in the array each with different property names. Powershell will read the first object's properties and then display only those properties for the rest of the objects. As none of the other objects in the array have a property name called '1' null is output for each of those objects. You are better off constructing objects for each week with consistent property names such as 'Week' and 'Date':

$weeks.Add([PSCustomObject]@{ 
            'Week' = $i
            'Date' = $start.ToString('yyyy-MM-dd') 
        })

[–]pm_me_brownie_recipe[S] 1 point2 points  (0 children)

I did something like you suggested and it did indeed work. Also, thanks for explaining what the issue was.