VMware Cloud Community
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Unable to get group-object captured in csv or excel

Hi,

I am unable to capture the capture of below command to .csv or excel

Get-VM | Group-Object HardwareVersion

As I am getting the output error as below in the output file

  

CountNameGroup
781vmx-15System.Collections.ObjectModel.Collection`1[System.Management.Automation.PSObject]
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

That is normal behaviour of the Expoert-Csv cmdlet.

When a property is not a singular value, but a collection, it will place the type of that property in that column in the CSV.

Assuming you want the names of the VMs on the HW version in the CSV, you could do something like

Get-VM | Group-Object HardwareVersion |

Select @{N='HWVersion';E={$_.Name}},  

    Count,

    @{N='VM';E={$_.Group.Name -join '|'}}


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

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

That is normal behaviour of the Expoert-Csv cmdlet.

When a property is not a singular value, but a collection, it will place the type of that property in that column in the CSV.

Assuming you want the names of the VMs on the HW version in the CSV, you could do something like

Get-VM | Group-Object HardwareVersion |

Select @{N='HWVersion';E={$_.Name}},  

    Count,

    @{N='VM';E={$_.Group.Name -join '|'}}


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

0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

oh, got it LucD.

Thank you very much. that worked Smiley Happy

0 Kudos