4 Replies Latest reply on Sep 11, 2019 10:33 PM by ganapa2000

    issue exporting iso path to excel

    ganapa2000 Hot Shot

      Hi,

       

      I have a issue exporting the below command output to excel

       

      get-vm | where { $_ | get-cddrive | where { $_.ConnectionState.Connected -eq "true" -and $_.ISOPath -like "*.ISO*"} } | select @{N="Folder";E={$_.Folder.Name}}, Name, @{N="ISO Path";E={(Get-CDDrive $_).isopath }} | Export-Excel -Path reportlocation1.xlsx

       

      When I execute the above command, in the ISO Path is incorrect, the same command works fine in the Powershell prompt

       

       

      Please help

        • 1. Re: issue exporting iso path to excel
          LucD Guru
          User ModeratorsCommunity WarriorsvExpert

          Do you have VMs with more than 1 CD drive?

          Try like this

           

          Get-VM | where { $_ | Get-CDDrive | where { $_.ConnectionState.Connected -eq "true" -and $_.ISOPath -like "*.ISO*"} } |

          select @{N="Folder";E={$_.Folder.Name}}, Name,

              @{N="ISO Path";E={(Get-CDDrive -VM $_).isopath -join '|' }} |

          Export-Excel -Path reportlocation1.xlsx

          Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
          • 2. Re: issue exporting iso path to excel
            ganapa2000 Hot Shot

            Thank you LucD,

             

            I have few VMs where 2 or more ISO are mounted. with the above script, I am getting as below

             

            Eg:

             

            Name     ISO Path

            VM1       ISO1| ISO2 | ISO3

             

            I would like to get VM Name and first ISO path in the one line

             

            Eg :

             

            Name     ISO Path

            VM1       ISO1

            VM1       ISO2

            VM1      ISO3

            • 3. Re: issue exporting iso path to excel
              LucD Guru
              vExpertUser ModeratorsCommunity Warriors

              Try like this

               

              Get-VM |

              Get-CDDrive |

              where { $_.ConnectionState.Connected -eq "true" -and $_.ISOPath -like "*.ISO*"} |

              select @{N="VM";E={$_.Parent.Name}},

                  @{N='ISO Path';E={$_.IsoPath}} |

              Export-Excel -Path reportlocation1.xlsx

               

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

               

              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
              • 4. Re: issue exporting iso path to excel
                ganapa2000 Hot Shot

                Perfect...thank you very much