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

by Grzegorz Kulikowski

That’s the only way so far i have figured out how to do it. Getting the information through CIM.
[sourcecode language=”powershell”]
$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()
[/sourcecode]
In return i get this:

[sourcecode language=”powershell”]
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
[/sourcecode]

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

You may also like

Leave a Reply

Chinese (Simplified)EnglishFrenchGermanHindiPolishSpanish
Streaming live on Twitch right now.
CURRENTLY OFFLINE