VMware Cloud Community
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Unable to export to csv

Hi,

I am unable to export the output to csv file, please help

$info = @()

$esxName = '10.10.10.10'

$esxcli = Get-EsxCli -VMHost $esxName

foreach($dev in $esxcli.hardware.pci.list()){

if($dev.ModuleName -ne 'None'){

$esxcli.system.module.get($dev.ModuleName) |

        Select @{N='Device';E={$dev.DeviceName}},@{N='DeviceClass';E={$dev.DeviceClassName}},Module,Version

    }

}

$info | Export-Csv ".\ESXi_Info0.csv" -NoTypeInformation -UseCulture

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try like this.
There is no need to fill the $info array, just export what comes through the pipeline.

$esxName = '10.10.10.10'

$esxcli = Get-EsxCli -VMHost $esxName

$esxcli.hardware.pci.list() |

where { $_.ModuleName -ne 'None' } |

ForEach-Object -Process {

   $dev = $_

   $esxcli.system.module.get($dev.ModuleName) |

  Select @{N = 'Device'; E = { $dev.DeviceName } },

   @{N = 'DeviceClass'; E = { $dev.DeviceClassName } }, Module, Version

} |

Export-Csv ".\ESXi_Info0.csv" -NoTypeInformation -UseCulture

------------------------------------------------------------------------------------------------------

Was it helpful? Let us know by completing this short survey here.


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

View solution in original post

2 Replies
LucD
Leadership
Leadership
Jump to solution

Try like this.
There is no need to fill the $info array, just export what comes through the pipeline.

$esxName = '10.10.10.10'

$esxcli = Get-EsxCli -VMHost $esxName

$esxcli.hardware.pci.list() |

where { $_.ModuleName -ne 'None' } |

ForEach-Object -Process {

   $dev = $_

   $esxcli.system.module.get($dev.ModuleName) |

  Select @{N = 'Device'; E = { $dev.DeviceName } },

   @{N = 'DeviceClass'; E = { $dev.DeviceClassName } }, Module, Version

} |

Export-Csv ".\ESXi_Info0.csv" -NoTypeInformation -UseCulture

------------------------------------------------------------------------------------------------------

Was it helpful? Let us know by completing this short survey here.


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

ganapa2000
Hot Shot
Hot Shot
Jump to solution

Thank you very much LucD.

That worked Smiley Happy

0 Kudos