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
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)
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)
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
Thanks on good advice and link, it was helpfull.
I find one more (fast) way: RV Tools.
Regards