VMware Cloud Community
MRoushdy
Hot Shot
Hot Shot

combining multi PowerCLI cmdlet results in a single CSV

Hello,

what's the possibility of combining the results of multiple cmdlet results in single CSV file, but to be formatted in a way that the result of each command/script to be listed one after another, not in horizontal columns. For example, I need to get the output of both 'get-vm" and "get-datastorecluster" in a single csv file.

Thanks,

vEXPERT - VCAP-DCV - Blog: arabitnetwork.com | YouTube: youtube.com/c/MohamedRoushdy
0 Kudos
2 Replies
LucD
Leadership
Leadership

That is not possible I'm afraid.

A CSV file, by definition, has normally a 1st row that names the columns in the row.
And the subsequent rows will have values for those columns.

You can't change the column names and layout half way through the CSV.
You can have all the properties/columns for both cmdlets, but then certain rows will have empty columns, depending on which cmdlet generated the values.

As an alternative, you can direct the output of the 2 cmdlets to one TXT file.

But then you will miss out on the Excel features that a CSV offers.

Another alternative is to use a XLSX file, and store the results of the two cmdlets in two different worksheets in that XLSX file.

That is something you can do with the ImportExcel module.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
MRoushdy
Hot Shot
Hot Shot

Thank you,

vEXPERT - VCAP-DCV - Blog: arabitnetwork.com | YouTube: youtube.com/c/MohamedRoushdy
0 Kudos