OutVariable
1 TopicTee-Object / -OutVariable into existing array (i.e., add into that array - is this doable?)
Hello, I have some Exchange reporting scripts where I'd like to offer the option to export CSV automatically but always send the output to standard output stream as well. I though about using Tee-Object like this: foreach ($y in $yadayada) { [PSCustomObject]@{ p1 = $y.v1 p2 = $y.v2 } | Tee-Object -Variable preExistingArray } I would later then like to do this: if ($ExportCSVs) { $preExistingArray | Export-Csv ... } ...and by that time, nobody was waiting at the console for all their objects to collect before being output all at once. That is the difference from my usual approach which is more like: 1-Collect everything into variable;2-output variable (all objects) to std output stream; 3-export to CSV. Thought I could use Tee-Object to combine 1 and 2. I don't think it's possible. So, wondering if anyone else has something clever in this area? Please do share.1.4KViews0likes4Comments