VMware Cloud Community
AdamRushUK
Enthusiast
Enthusiast
Jump to solution

Find out which VMs have mounted a certain VMDK

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.

Multiple-VMs-Attached-to-Disk.PNG

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?

VCP-Cloud | VCP5-DCV | MCITP:EA | MCSE | CCNA | CCAA LinkedIn: https://www.linkedin.com/in/adamrushuk | Twitter : @adamrushuk
Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

View solution in original post

Reply
0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
AdamRushUK
Enthusiast
Enthusiast
Jump to solution

Worked a treat, thanks Luc!

VCP-Cloud | VCP5-DCV | MCITP:EA | MCSE | CCNA | CCAA LinkedIn: https://www.linkedin.com/in/adamrushuk | Twitter : @adamrushuk
Reply
0 Kudos
jjwb96
Contributor
Contributor
Jump to solution

Still works in 2021! Thanks! Saved my a** with a writable volume that didn't detach properly! Thanks!

Reply
0 Kudos