The xml parser treats the child nodes differently while converting to PS objects. It casts it to single XML Element when there is only one child node but an array of objects if more. Hence, it will fail with "no Count property" error when the itemgroup is accessed as $Project.Project.ItemGroup[0].DataSource.Count or $Project.Project.ItemGroup[1].Report.Count when there's only one dataSource/report.
The fix simply convert it into array explicitly beforehand and assign with variable other than accessing directly from $project.
The xml parser treats the child nodes differently while converting to PS objects. It casts it to single XML Element when there is only one child node but an array of objects if more. Hence, it will fail with "no Count property" error when the itemgroup is accessed as
$Project.Project.ItemGroup[0].DataSource.Count
or$Project.Project.ItemGroup[1].Report.Count
when there's only one dataSource/report.The fix simply convert it into array explicitly beforehand and assign with variable other than accessing directly from $project.