What's the fastest way to find out which VMs have a certain VMDK attached?
I can see in vCenter > Storage Reports (Virtual Machine Files) that the Number of VMs on a certain VMDK shows as 2.
This usually means that a Backup Proxy VM still has it attached, but not in this case, so it must be attached to another VM.
What's the fastest way to find which VMs are connected to a VMDK file using PowerCLI?
Did you already try like this?
$vmdkName = '[DS] vm/vm.vmdk'
Get-View -ViewType VirtualMachine -Property Name,Config.Hardware.Device |
where{$_.Config.Hardware.Device | where{$_ -is [VMware.Vim.VirtualDisk] -and $_.Backing.Filename -eq $vmdkName}} |
Select Name
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Did you already try like this?
$vmdkName = '[DS] vm/vm.vmdk'
Get-View -ViewType VirtualMachine -Property Name,Config.Hardware.Device |
where{$_.Config.Hardware.Device | where{$_ -is [VMware.Vim.VirtualDisk] -and $_.Backing.Filename -eq $vmdkName}} |
Select Name
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Worked a treat, thanks Luc!
Still works in 2021! Thanks! Saved my a** with a writable volume that didn't detach properly! Thanks!