How to get a list of hard disks in ESXi host system ?

That’s the only way so far i have figured out how to do it. Getting the information through CIM.

$esxi = 'myhost'
$CIMOpt = New-CimSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck -Encoding Utf8 –UseSsl
$Session = New-CimSession -Authentication Basic -Credential $cred -ComputerName $esxi -port 443 -SessionOption $CIMOpt
Get-CimInstance -CimSession $Session -Namespace 'root/cimv2' -ClassName 'CIM_StorageExtent' | ?{$_.CreationClassName -eq 'HPVC_SAStorageExtent'} | Select PSComputerName, Caption, ElementName
$session.close()

In return i get this:

PSComputerName Caption ElementName
-------------- ------- -----------
esxi01.local.lan Disk 1 on HPSA1 Disk 1 on HPSA1 : Port 1I Box 1 Bay 1 : 136GB : Data Disk
esxi02.local.lan Disk 2 on HPSA1 Disk 2 on HPSA1 : Port 1I Box 1 Bay 2 : 136GB : Data Disk

This will work only for HP in this version as i am filtering output with HPVC_SAStorageExtent
Well, better this than nothing 😉

Advertisements