Automation

 View Only
  • 1.  How to list virtual machines with related vmdk files

    Posted Jan 19, 2013 08:51 PM

    Hi.

    I have a vmfs folder and vmdk file with names which are not like any virtual machine name (probably becouse renaming VM name).

    How can I find what VM is it?

    Thanks



  • 2.  RE: How to list virtual machines with related vmdk files
    Best Answer

    Posted Jan 19, 2013 09:16 PM

    Hello, biokovo-

    You could use the standard Get-VM and Get-HardDisk cmdlets to find names of VMDKs associated with VMs.  Or, another, far faster way, would be to use everyone's favorite:  Get-View.

    Since you know the datastore path for the VMDK, you can check the LayoutEx property of VMs to find the VM that has the File property with the Name value that matches said datastore path, like:

    $strVmdkDatastorePath = "[mydatastore] somefolder/somefile.vmdk"
    Get-View -ViewType VirtualMachine -Property Name,LayoutEx.File | ?{$_.LayoutEx.File | ?{$_.Name -eq $strVmdkDatastorePath}} | select name

    Where the datastore path is of format, "[datastoreName] folder/somefile.vmdk".  Yes, including the square brackets around the datastore name, and a space after the "]" (before the first character of the folder name).

    How does that do for you?  (should be right quick)



  • 3.  RE: How to list virtual machines with related vmdk files

    Posted Jan 21, 2013 07:58 AM

    Hi,

    I had the same problem, I use the script you can find here:

    http://www.running-system.com/code-snippet-report-with-vm-name-lun-name-vmdk-file-and-path/

    Regards

    Andi



  • 4.  RE: How to list virtual machines with related vmdk files

    Posted Jan 21, 2013 09:59 PM

    Thanks on good advice and link, it was helpfull.

    I find one more (fast) way: RV Tools.

    Regards