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
Hello.
Do you know RVTools? Maybe the quick way to get this info.
Regards
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
I know, but I need to automate the process.
thanks
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