VMware Cloud Community
Bibsy
Contributor
Contributor

PowerCLI question - resolve the Datastore Name to LUN ID

Hello,

I'm new to PowerCLI and I am trying to run a report which will resolve the Datastore Name to my LUN ID so that I can start cleaning up my datastore. I have this script -

Powershell

Get-DataStore | Get-ScsiLun -CanonicalName "naa.*" | Export-Csv C:\Users\bsodd\LUNid.csv 

Which works well but doesn't give the info I need unfortunately.

How do I get the Datastore Name to resolve to the LUN ID, is there a script that I can use to get this info?

Thanks in advance

0 Kudos
2 Replies
brunofernandez1

you were on the right way

the lun ID is defined in the property runtimeName of get-scsilun :

PowerCLI C:\> $datastore[0] | select *

Id                  : HostSystem-host-65536/naa.600014400000001020248cb06552602b

CanonicalName        : naa.600014400000001020248cb06552602b

RuntimeName          : vmhba0:C0:T4:L1

Key                  : key-vim.host.ScsiDisk-0200010000600014400000001020248cb06552602b496e76697374

LunType              : disk

Model                : Invista

SerialNumber        : unavailable

Vendor              : EMC

ConsoleDeviceName    : /vmfs/devices/disks/naa.600014400000001020248cb06552602b

CapacityMB          : 1536000

CapacityGB          : 1500

MultipathPolicy      : RoundRobin

CommandsToSwitchPath : 1000

BlocksToSwitchPath  : 10240

HostId              : HostSystem-host-65536

VMHostId            : HostSystem-host-65536

VMHost              :

Uid                  : /VIServer=3/VMHost=HostSystem-host-65536/ScsiLun=naa.600014400000001020248

                      cb06552602b/

IsLocal              : False

ExtensionData        : VMware.Vim.HostScsiDisk

the last part of the RuntimeName is the LUNID. In this emxample LUNID 1

to get the datastore name i would recommend to create a custom object

------------------------------------------------------------------------------- If you found this or any other answer helpful, please consider to award points. (use Correct or Helpful buttons) Regards from Switzerland, B. Fernandez http://vpxa.info/
0 Kudos
brunofernandez1

this could also help:

How to get LUN ID ?

------------------------------------------------------------------------------- If you found this or any other answer helpful, please consider to award points. (use Correct or Helpful buttons) Regards from Switzerland, B. Fernandez http://vpxa.info/
0 Kudos