VMware Cloud Community
ganapa2000
Hot Shot
Hot Shot
Jump to solution

How to get eui id using VML ID ?

Hi,

I have the below script which provide me the eui and its associated vml

$esxName = "myesx01"
$esx = Get-VMHost $esxName
$esx.ExtensionData.Config.StorageDevice.ScsiLun |
Select @{N="ESX";E={$esx.Name}},
CanonicalName,
@{N="VML";E={$_.Descriptor | where {$_.Id -match "^vml"} | Select -ExpandProperty Id}} | ft -auto

I would like to know, how can i get the eui details using the vml which I have ?

Please help!!!

Reply
0 Kudos
1 Solution

Accepted Solutions
Dharzhak
Enthusiast
Enthusiast
Jump to solution

Okay, so "VML" is a calculated property. I gotcha now. Seems overly complex, but I can roll with it.

Here's the thing, since that's not a standard property, you need to provide that context in order to use it:

If you plan on reusing that property, you should save it into an array:

$myvml = "01000300003431373861313338313438323331373136633963653930303430636430336264536572766572"
$VMLObjs = $esx.ExtensionData.Config.StorageDevice.ScsiLun | Select-Object @{N="ESX";E={$esx.Name}}, CanonicalName, @{N="VML";E={$_.Descriptor | where {$_.Id -match "^vml"} | Select -ExpandProperty Id}}
$VMLObjs | Where-Object {$_.VML -match $myvml }

If you don't plan on reusing your calculated VML property, then you can just pipe it into Where-Object:

$esx.ExtensionData.Config.StorageDevice.ScsiLun | Select-Object @{N="ESX";E={$esx.Name}}, CanonicalName, @{N="VML";E={$_.Descriptor | where {$_.Id -match "^vml"} | Select -ExpandProperty Id}} | Where-Object {$_.VML -match $myvml }

If you don't want the hassle of a calculated property, you can just match $myvml to the Uuid property, as suggested above. Whatever works for ya.

View solution in original post

Reply
0 Kudos
19 Replies
LucD
Leadership
Leadership
Jump to solution

WHat do you mean by "eui details"?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

LucD,

like naa id, few storage would have eui id for the volumes.

ganapa2000_0-1638183454063.png

 

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

If you want to select a LUN via a specific EUI, then you would need to use a Where-clause.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

LucD,

I have a vml id, I need to get the eui id using that ? not sure, how to get that ?

I tried as below, but it returns blank

$myvml = "01000300003431373861313338313438323331373136633963653930303430636430336264536572766572"
$esxName = "myesx"
$esx = Get-VMHost $esxName
$esx.ExtensionData.Config.StorageDevice.ScsiLun | Select @{N="VML1";E={$_.Descriptor | where {"^eui" -match $myvml} | Select -ExpandProperty Id}} | ft -auto

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Would this work?

$myvml = "01000300003431373861313338313438323331373136633963653930303430636430336264536572766572"
$esxName = "myesx"
$esx = Get-VMHost $esxName
$esx.ExtensionData.Config.StorageDevice.ScsiLun |
where{$_.Vml -match $myVML} |
Select CanonicalName


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Not, it shows blank 😞

If I execute excluding where, I get below

$myvml = "01000300003431373861313338313438323331373136633963653930303430636430336264536572766572"
$esxName = "myesx"
$esx = Get-VMHost $esxName
$esx.ExtensionData.Config.StorageDevice.ScsiLun

ganapa2000_0-1638186968945.png

 

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You didn't use the Where-clause


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

I used the where clause, I got blank output

Reply
0 Kudos
Dharzhak
Enthusiast
Enthusiast
Jump to solution

This is all one line:

$esx.ExtensionData.Config.StorageDevice.ScsiLun | Where-Object {$_.Vml -match $myVML} | Select-Object -Property CanonicalName

Reply
0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

yes, I tried the same, but still not getting the any output

$myvml = "vml.01000300003431373861313338313438323331373136633963653930303430636430336264536572766572"
$esxName = "myesx"
$esx = Get-VMHost $esxName
$esx.ExtensionData.Config.StorageDevice.ScsiLun | where{$_.vml -match $myvml} | Select CanonicalName

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Where did you get that VML property from in the screenshot?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Dharzhak
Enthusiast
Enthusiast
Jump to solution

Okay, then then it means that none of the LUNS are matching that ID number. You can verify that by taking the Where-Object statement out and viewing the results:

$esx.ExtensionData.Config.StorageDevice.ScsiLun | Select-Object -Property CanonicalName

I'd also suggest assigning $myvml dynamically, rather than setting it as a static value in case it changes, but that's a bit of a quibble.

Reply
0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

vml exists and I am able to get the canonical name, but rather going through huge list, I would like to query the vml to get the corresponding canonical name

4th one in the below the output is the vml, that i am querying

ganapa2000_0-1638195263402.png

 

Reply
0 Kudos
Dharzhak
Enthusiast
Enthusiast
Jump to solution

Yeah, good catch. I didn't even think about the fact that "vml" isn't even a listed property. I haven't finished my second tankard of coffee yet. He should be comparing $MyVML to $_.Uuid  


ganapa2000, the statement should be:

$esx.ExtensionData.Config.StorageDevice.ScsiLun | Where-Object {$_.Uuid -match $myVML} | Select-Object -Property CanonicalName

Reply
0 Kudos
Dharzhak
Enthusiast
Enthusiast
Jump to solution

I'd like to see the command you used to list the VML property in your second screenshot, because I don't see that property in the first one.

Can you also add the LunType property?

Reply
0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

here is the command, which i used

$esxName = "myesx"
$esx = Get-VMHost $esxName
$esx.ExtensionData.Config.StorageDevice.ScsiLun |
Select @{N="ESX";E={$esx.Name}},
CanonicalName,
@{N="VML";E={$_.Descriptor | where {$_.Id -match "^vml"} | Select -ExpandProperty Id}} | ft -auto

Reply
0 Kudos
Dharzhak
Enthusiast
Enthusiast
Jump to solution

Okay, so "VML" is a calculated property. I gotcha now. Seems overly complex, but I can roll with it.

Here's the thing, since that's not a standard property, you need to provide that context in order to use it:

If you plan on reusing that property, you should save it into an array:

$myvml = "01000300003431373861313338313438323331373136633963653930303430636430336264536572766572"
$VMLObjs = $esx.ExtensionData.Config.StorageDevice.ScsiLun | Select-Object @{N="ESX";E={$esx.Name}}, CanonicalName, @{N="VML";E={$_.Descriptor | where {$_.Id -match "^vml"} | Select -ExpandProperty Id}}
$VMLObjs | Where-Object {$_.VML -match $myvml }

If you don't plan on reusing your calculated VML property, then you can just pipe it into Where-Object:

$esx.ExtensionData.Config.StorageDevice.ScsiLun | Select-Object @{N="ESX";E={$esx.Name}}, CanonicalName, @{N="VML";E={$_.Descriptor | where {$_.Id -match "^vml"} | Select -ExpandProperty Id}} | Where-Object {$_.VML -match $myvml }

If you don't want the hassle of a calculated property, you can just match $myvml to the Uuid property, as suggested above. Whatever works for ya.

Reply
0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Perfect...Since I wanted only the canonical name using the vml id, I modified as below and that worked 🙂

Thank you very much 🙂

$myvml = "01000300003431373861313338313438323331373136633963653930303430636430336264536572766572"
$esxName = "myesx"
$esx = Get-VMHost $esxName
$VMLObjs = $esx.ExtensionData.Config.StorageDevice.ScsiLun | Select-Object @{N="ESX";E={$esx.Name}}, CanonicalName, @{N="VML";E={$_.Descriptor | where {$_.Id -match "^vml"} | Select -ExpandProperty Id}}
$VMLObjs | Where-Object {$_.VML -match $myvml} | Select -ExpandProperty CanonicalName

Reply
0 Kudos
Dharzhak
Enthusiast
Enthusiast
Jump to solution

Awesome. Glad I could help.

Reply
0 Kudos