VMware Cloud Community
ganapa2000
Hot Shot
Hot Shot
Jump to solution

IsPerenniallyReserved status shows blank

Hi,

Unable to get IsPerenniallyReserved status as it shows blank

Get-VMHost 172.27.3.8 | Get-ScsiLun -LunType disk |

Select VMHost,

    @{n='LUN';E={

        $esxcli = Get-EsxCli -VMHost $_.VMHost -V2

        $esxcli.storage.nmp.path.list.Invoke(@{'device'=$_.CanonicalName}).RuntimeName.Split(':')[-1].TrimStart('L')}},

Vendor, LunType,CapacityGB, MultipathPolicy,

@{N='IsPerenniallyReserved';E={($esxcli.storage.core.device.list.invoke(@{'device'=$_.CanonicalName}) | Select -ExpandProperty IsPerenniallyReserved)}} |

Sort-Object -Property {[int]$_.LUN} | ft -auto

Please help.

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Does this return the LUN ID?

$esxcli = Get-VMHost -Name 172.27.3.8 | Get-EsxCli -v2

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

where{$_.DeviceType -eq 'Direct-Access'} |

Select Vendor, DeviceType,

   @{N='CapacityGB';E={$_.Size/1KB}},

   @{N='MultipathPolicy';E={($esxcli.storage.nmp.device.list.Invoke(@{device=$_.Device})).PathSelectionPolicy}},

   @{N='LUN';E={($esxcli.storage.nmp.path.list.Invoke(@{device=$_.Device})).RuntimeName.Split(':')[-1].TrimStart('L')}},

  IsPerenniallyReserved,

   @{N='ConsoleDeviceName';E={$_.DevfsPath}}


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

View solution in original post

0 Kudos
8 Replies
LucD
Leadership
Leadership
Jump to solution

You can do this all with Get-EsxCli, which is a lot faster than Get-ScsiLun.
Something like this

$esxcli = Get-VMHost -Name 172.27.3.8 | Get-EsxCli -v2

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

where { $_.DeviceType -eq 'Direct-Access' } |

Select Vendor, DeviceType,

@{N = 'CapacityGB'; E = { $_.Size / 1KB } },

@{N = 'MultipathPolicy'; E = { ($esxcli.storage.nmp.device.list.Invoke(@{device = $_.Device })).PathSelectionPolicy } },

@{N = 'LUN'; E = { $_.Device.Split(':')[-1].TrimStart('L') } },

IsPerenniallyReserved


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

0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

LucD,

Now I am able to get IsPerenniallyReserved but I unable to get ConsoleDeviceName and LUN ID as both shows blank

$esxcli = Get-VMHost -Name 172.27.3.8 | Get-EsxCli -v2

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

where { $_.DeviceType -eq 'Direct-Access' } |

Select Vendor, DeviceType,

@{N = 'CapacityGB'; E = { $_.Size / 1KB } },

@{N = 'MultipathPolicy'; E = { ($esxcli.storage.nmp.device.list.Invoke(@{device = $_.Device })).PathSelectionPolicy } },

@{N = 'CanonicalName'; E = { $_.Device.Split(':')[-1].TrimStart('L') } },

@{N='LUN ID'; E={$d = $_; ((Get-ScsiLun -VmHost $esxcli | Where {$_.CanonicalName -eq $_.Device}).RuntimeName -split ':' | Select -last 1).TrimStart('L')}},

IsPerenniallyReserved, ConsoleDeviceName | ft  -auto

0 Kudos
LucD
Leadership
Leadership
Jump to solution

The ConsoelDeviceName is shown as DevfsPath.

$esxcli = Get-VMHost -Name 172.27.3.8 | Get-EsxCli -v2

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

where { $_.DeviceType -eq 'Direct-Access' } |

Select Vendor, DeviceType,

@{N = 'CapacityGB'; E = { $_.Size / 1KB } },

@{N = 'MultipathPolicy'; E = { ($esxcli.storage.nmp.device.list.Invoke(@{device = $_.Device })).PathSelectionPolicy } },

@{N = 'LUN'; E = { $_.Device.Split(':')[-1].TrimStart('L') } },

IsPerenniallyReserved,

@{N = 'ConsoleDeviceName'; E = { $_.DevfsPath } }


The LUN ID works for me. How is the Device returned in your environment?

Do a


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

where { $_.DeviceType -eq 'Direct-Access' } | Select Device


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

0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Hi LucD,

Sorry for the confusion, I can see LUN like naa.60030130......but I would like to get the LUN number (2 or 3 or 5) of the device on the host.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

No problem.
Is that LUN ID available in any of the following properties?

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

where { $_.DeviceType -eq 'Direct-Access' } |

Select Device, DevfsPath, DisplayName

If not, can you show me the complete output for 1 LUN?

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

where { $_.DeviceType -eq 'Direct-Access' } |

Select -First 1 -Property *


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

0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

LucD,

I need the LUN Number as below

pastedImage_0.png

also I dont see LUN number from below query.

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

where { $_.DeviceType -eq 'Direct-Access' } |

Select Device, DevfsPath, DisplayName

If not, can you show me the complete output for 1 LUN?

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

where { $_.DeviceType -eq 'Direct-Access' } |

Select -First 1 -Property *

pastedImage_1.png

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Does this return the LUN ID?

$esxcli = Get-VMHost -Name 172.27.3.8 | Get-EsxCli -v2

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

where{$_.DeviceType -eq 'Direct-Access'} |

Select Vendor, DeviceType,

   @{N='CapacityGB';E={$_.Size/1KB}},

   @{N='MultipathPolicy';E={($esxcli.storage.nmp.device.list.Invoke(@{device=$_.Device})).PathSelectionPolicy}},

   @{N='LUN';E={($esxcli.storage.nmp.path.list.Invoke(@{device=$_.Device})).RuntimeName.Split(':')[-1].TrimStart('L')}},

  IsPerenniallyReserved,

   @{N='ConsoleDeviceName';E={$_.DevfsPath}}


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

0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Perfect, that worked Smiley Happy

Thank you very much.

0 Kudos