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.
Does this return the LUN ID?
$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
You can do this all with Get-EsxCli, which is a lot faster than Get-ScsiLun.
Something like this
$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
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
The ConsoelDeviceName is shown as DevfsPath.
$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
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.
No problem.
Is that LUN ID available in any of the following properties?
where { $_.DeviceType -eq 'Direct-Access' } |
Select Device, DevfsPath, DisplayName
If not, can you show me the complete output for 1 LUN?
where { $_.DeviceType -eq 'Direct-Access' } |
Select -First 1 -Property *
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
I need the LUN Number as below
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 *
Does this return the LUN ID?
$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
Perfect, that worked
Thank you very much.