VMware Cloud Community
malabelle
Enthusiast
Enthusiast
Jump to solution

CSV of VM, VMDK, LUNs, Path

Hi,

I'm completely blocked on this one.

I need to get a report in CSV telling me those things:

VM name, vmdk filename, LUN

Bonusely, adding Drive letter and vmhost would be cool.

have you any ideas?

vExpert '16, VCAP-DCA, VCAP-DCD
Tags (3)
0 Kudos
1 Solution

Accepted Solutions
Zsoldier
Expert
Expert
Jump to solution

This'll probably work:

$vms = Get-VM

$vmdisks = $vms | % {$_.Harddisks}

$Report = @()

Foreach ($vmdisk in $vmdisks)

{

$NewObject = "" | Select VMName, vmdkFileName, LUN, Host

$NewObject.VMName = $vmdisk.parent

$NewObject.vmdkFileName = $vmdisk.filename

$NewObject.LUN = (get-datastore $vmdisk.parent).Name

$NewObject.Host = ($vms | where-object {$_.ID -eq $vmdisk.parentid}).Host

$Report += $NewObject

}

$Report | export-csv C:\temp\nameofcsv.csv

Filename and LUN may be redundant, but it'll get you what you are looking for.  LUN number in particular is a difficult thing to find in vSphere as the backend translation would likely need to occur.

Message was edited by: Zsoldier

Chris Nakagaki (中垣浩一)
Blog: https://tech.zsoldier.com
Twitter: @zsoldier

View solution in original post

0 Kudos
4 Replies
xacolabril
Expert
Expert
Jump to solution

Hello.

Do you know RVTools? Maybe the quick way to get this info.

Regards

Xavier Colomé Abril. VMware Certified Professional VCP3, VCP4 and VCP5. [Si encuentras que esta o cualquier otra respuesta ha sido de utilidad, vótalas. Gracias.] [If you find this or any other information helpful or correct, please consider awarding points. Thank you.]
0 Kudos
nkrishnan
Expert
Expert
Jump to solution

Most of the details you can get it in VI or VC. Go to perticular window, right click on it and select export in to CVS,html etc format

Eg: Go to Configuration->Storage tab and right click to get the datastore details.

Nithin

--Nithin
0 Kudos
malabelle
Enthusiast
Enthusiast
Jump to solution

I know, but I need to automate the process.

thanks

vExpert '16, VCAP-DCA, VCAP-DCD
0 Kudos
Zsoldier
Expert
Expert
Jump to solution

This'll probably work:

$vms = Get-VM

$vmdisks = $vms | % {$_.Harddisks}

$Report = @()

Foreach ($vmdisk in $vmdisks)

{

$NewObject = "" | Select VMName, vmdkFileName, LUN, Host

$NewObject.VMName = $vmdisk.parent

$NewObject.vmdkFileName = $vmdisk.filename

$NewObject.LUN = (get-datastore $vmdisk.parent).Name

$NewObject.Host = ($vms | where-object {$_.ID -eq $vmdisk.parentid}).Host

$Report += $NewObject

}

$Report | export-csv C:\temp\nameofcsv.csv

Filename and LUN may be redundant, but it'll get you what you are looking for.  LUN number in particular is a difficult thing to find in vSphere as the backend translation would likely need to occur.

Message was edited by: Zsoldier

Chris Nakagaki (中垣浩一)
Blog: https://tech.zsoldier.com
Twitter: @zsoldier
0 Kudos