Recently I was trouble shooting a Zerto issue that occurred due to a storage “blip”. Some Zerto Z-VRAHs had lost disks and many VPGs where in an error state. One of the shadow Z-VRAs had lost its 4 “OS” disks. These disks are copied from the ZVM and are device 0 on SCSI busses 0-3. Easley fixed once once identified but how many other Z-VRAHs where the with one or more missing “OS” disks?
So, here is a quick script I put together to get the SCSI bus, device number and a couple of other bits of VM hard drive info. Later Ill expand the script to detect thick/thin provisioned disks and used size.
When run you will get an array called report that will look something like this.
- VM name
- The disk name as shown in the VM settings
- Path to the VMDK
- SCSI bus number
- SCSI device/unit ID
- Disk Size in Kbytes, This is the capacity not the actual size of the VMDK
- Controller key

Here is the script.
$VMs = get-VM jason* # enter the name / part of name / or just use get-vm for everything
$Report = @()
foreach ($VM in $VMs)
{
# get the HDs on the VM so we can loop though each one.
$HDs = $vm | get-harddisk
foreach ($HD in $HDs)
{
# match this HD to the HW device info in the VM.ExtensionData object list
$CKey = $hd.ExtensionData.ControllerKey
$Device = $vm.Extensiondata.Config.Hardware.Device | where{$_.Key -eq $CKey}
# create a temp object for each HD
$tmpDiskObj = '' | select VM,Disk,Path,SCSIBus,SCSIUnit,CapacityKB,cKey
$tmpDiskObj.VM = $VM.name
$tmpDiskObj.Disk = $HD.Name
$tmpDiskObj.SCSIBus = $Device.BusNumber
$tmpDiskObj.SCSIUnit = $hd.ExtensionData.UnitNumber
$tmpDiskObj.Path = $HD.FileName
$tmpDiskObj.CapacityKB= $HD.CapacityKB
$tmpDiskObj.cKey = $CKey
$Report += $tmpDiskObj
}
}
$Report | ft
Hope that is some use to some one.
If it helps. Here is that same code but as a function.
To call the function use this
- $VMs | Get-VMDiskInfo
- Get-VMDiskInfo -VM $VMs
- “MyVMName” | Get-VMDiskInfo
- Get-VMDiskInfo | -VM “MyVMName”
function Get-VMDiskInfo
{
[CmdletBinding()]
param(
[Parameter(ValueFromPipeline=$true)] $VM
)
if ($VM -is [string]){$VMs = get-vm $VM -ErrorAction SilentlyContinue}
if ($VM -is [VMware.VimAutomation.ViCore.Impl.V1.VM.UniversalVirtualMachineImpl]){$VMs = $VM}
if ($VMs)
{
$Report = @()
foreach ($VM in $VMs)
{
# get the HDs on the VM so we can loop though each one.
$HDs = $vm | get-harddisk
foreach ($HD in $HDs)
{
# match this HD to the HW device info in the VM.ExtensionData object list
$CKey = $hd.ExtensionData.ControllerKey
$Device = $vm.Extensiondata.Config.Hardware.Device | where{$_.Key -eq $CKey}
# create a temp object for each HD
$tmpDiskObj = '' | select VM,Disk,Path,SCSIBus,SCSIUnit,CapacityKB,cKey
$tmpDiskObj.VM = $VM.name
$tmpDiskObj.Disk = $HD.Name
$tmpDiskObj.SCSIBus = $Device.BusNumber
$tmpDiskObj.SCSIUnit = $hd.ExtensionData.UnitNumber
$tmpDiskObj.Path = $HD.FileName
$tmpDiskObj.CapacityKB= $HD.CapacityKB
$tmpDiskObj.cKey = $CKey
$Report += $tmpDiskObj
}
}
Return $Report
}else{
Write-Host "No VMs found" -ForegroundColor Red
Return $null
}
}