Hi Folks,
I would like to link 3 parameters, ConsoleDeviceName, CanonicalName and "Datastore Name".
The twice first (ConsoleDeviceName, CanonicalName) can i get with "Get-VMHost "MyESXHost" | Get-ScsiLun"
but how can I get the Datastore Name ?
thanks for help
Hi,
In order to get datastore name for each lun you need to examine disk extent information for each datastore attached to the host and link them using lun cannonical names. VMFS datastore disk extent information is available in HostScsiDiskPartition object. Here is an example code how to do that:
$h = Get-VMhost "MyESXHost" # collect VMFS datastore name and extent cannonical names into a hashtable $dsLunList = @{} $dsView = $h | Get-Datastore | ? {$_.Type -eq "VMFS"} | Get-View foreach ($ds in $dsView) { foreach ($diskExtent in $ds.Info.Vmfs.Extent) { $dsLunList[http://$diskExtent.DiskName|http://$diskExtent.DiskName] = $ds.Info.Name } } #populate datastore name for each lun if available $lunList = @() $h | Get-ScsiLun | % { $lun = "" | select ConsoleDeviceName, CanonicalName, DatastoreName $lun.ConsoleDeviceName = $_.ConsoleDeviceName $lun.CanonicalName = $_.CanonicalName if ($dsLunList.ContainsKey($_.CanonicalName)) { $lun.DatastoreName = $dsLunList[http://$_.CanonicalName|http://$_.CanonicalName] } $lunList += $lun } $lunList
Regards,
Yasen
Hi,
In order to get datastore name for each lun you need to examine disk extent information for each datastore attached to the host and link them using lun cannonical names. VMFS datastore disk extent information is available in HostScsiDiskPartition object. Here is an example code how to do that:
$h = Get-VMhost "MyESXHost" # collect VMFS datastore name and extent cannonical names into a hashtable $dsLunList = @{} $dsView = $h | Get-Datastore | ? {$_.Type -eq "VMFS"} | Get-View foreach ($ds in $dsView) { foreach ($diskExtent in $ds.Info.Vmfs.Extent) { $dsLunList[http://$diskExtent.DiskName|http://$diskExtent.DiskName] = $ds.Info.Name } } #populate datastore name for each lun if available $lunList = @() $h | Get-ScsiLun | % { $lun = "" | select ConsoleDeviceName, CanonicalName, DatastoreName $lun.ConsoleDeviceName = $_.ConsoleDeviceName $lun.CanonicalName = $_.CanonicalName if ($dsLunList.ContainsKey($_.CanonicalName)) { $lun.DatastoreName = $dsLunList[http://$_.CanonicalName|http://$_.CanonicalName] } $lunList += $lun } $lunList
Regards,
Yasen
Big Thanks ! Yasen, that is what I want