I'm lookng to use get-view to replace get-datastore "datastore" | get-scsilun. This gives me exactly what I need, but it's very slow in my environment due to lots of datastores. I mainly just need the naa number. Is this possible? I've found ways to get the naa numbers from the hosts through get-view, but not sure how to tie it to the specific datastore. I've looked through all the values for get-view -ViewType datastore and get-view -viobject "datastore", but maybe I'm missing something. I don't expect anyone to write it for me, just wondering if anyone could point me to where to look.
Thanks
Provided you only have VMFS datastores, you can do
Get-View -ViewType Datastore |
Select Name,@{N='naa';E={$_.Info.Vmfs.Extent[0].diskName}}
Note that this will only show the 1st extent of the datastore.
If you have datastores with more than 1 extent, the script will need to be adapted.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks Luc!
You can also try the following:
$esxcli= Get-EsxCli -VMHost $esxihost
$esxcli.storage.vmfs.extent.list() | ?{($_.DeviceName -like "naa.6000*")} | Sort Device | Select DeviceName, VolumeName
where $esxihost is your host name. Replace "naa.6000*" with your device identifier.