I have a collection of objects, each one with one property called as ProductName. I also defined a function to get parts for a product:
function GetParts([string] ProductName))
{
$parts = @()
....
return $parts
}
What I need is to use pipe to loop each object and add "Parts" as another property to the object by calling my function, and finally output the collection to a table view:
$products | Sort-Object ProductName | Select-Object `
-Property ProductName, `
@{Expression=(GetParts $_.ProductName); Label="Parts"} | `
Format-Table ProductName, Parts
I put a break point in my function, but I don't get debug stop. Not sure how to use pipe for a collection with my function to add a dynamic property (Parts).
ProductName, and the second being an array of stringsParts. Is that right? Or do you want it to output an array of objects that have 2 properties, one being a string for theProductNameand then each individual part that makes up the collection ofParts?ProductNameandParts(an array of strings). Is there any way to use pipe to call my function to output information I need?