VMware Cloud Community
ganapa2000
Hot Shot
Hot Shot
Jump to solution

issue exporting iso path to excel

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

pastedImage_2.png

Please help

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

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: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

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

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Perfect...thank you very much Smiley Happy

Reply
0 Kudos