Reply to Message

View discussion in a popup

Replying to:
CannibalDuck
Contributor
Contributor

Find a datastore, canonical name and runtime having just a LUN Id

I need help. I'm trying to make a "translator script" for our network engineers, so they can find most wanted LUN details for them.

Plan is simple: we know LUN Id (simple digits in the LUN column), and by knowing this, we must find NAA (canonical name), runtime name (ldev is kinda important), RDM (what virtual machine have this LUN) and datastore.

ATM im trying to use this script (thank you, LucD):

foreach ($clusterName in Get-Cluster) {

$report += Get-Cluster -Name $clusterName | Get-VMHost | %{

    $esxcli = Get-EsxCli -VMHost $_

    $esxcli.storage.core.device.list() |

    Select @{N='ESX';E={$esxcli.VMHost.Name}},Device,

      @{N='lunID'; E={

        $d = $_

        if(([Version]$esxcli.VMHost.Version).Major -lt 6){

          $lun = Get-ScsiLun -VmHost $esxcli.VMhost | Where {$_.CanonicalName -eq $d.Device}

          $runtime = $lun.RuntimeName

        }

        else{

          $lun = $esxcli.VMHost.ExtensionData.Config.StorageDevice.ScsiLun | Where-Object{$_.CanonicalName -eq $d.Device}

          $lunUuid = $lun.Uuid

          $runtime = ($esxcli.VMHost.ExtensionData.Config.StorageDevice.MultipathInfo.Lun | Where-Object{$_.Id -eq $lunUuid}).Path[0].Name

        }

        $runtime.Split('L')[1]

        }}      

}

}

$report

But it's rly slow, because it's trying to do with every host.. And if i'll try to search the datastores, it will take forever.. But anyway. I need help with this task. How can I find all I want, knowing just LUN Id? This task is hard for me.

P.S. Powercli version 6.5

Reply
0 Kudos