2 Replies Latest reply on Aug 19, 2019 4:45 AM by ganapa2000

    Unable to export to csv

    ganapa2000 Hot Shot

      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. Re: Unable to export to csv
          LucD Guru
          vExpertCommunity WarriorsUser Moderators

          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: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
          1 person found this helpful
          • 2. Re: Unable to export to csv
            ganapa2000 Hot Shot

            Thank you very much LucD.

             

            That worked