VMware Cloud Community
pbalderos
Enthusiast
Enthusiast

Unable to locate VM and VMX file after unregistered it from a host

Hello Community

I am running into a strange issue for the first time. I unregistered a VM in vCenter. I failed to note which data store it was housed on. I went to reregister it and I cannot find the folder or, of course the vmx file. I looked though each datastore and when I looked at the events on the cluster level it only shows i unregistered it. I did the same thing to several other VMs without issue. Any recommendations on where else I can look or or some powercli command I can use to find it?

Thanks in advance!

Phillip Balderos VCP6-DCV
0 Kudos
4 Replies
BenediktFrenzel
VMware Employee
VMware Employee

You may want to login to one of your hosts using ssh and run a simple find command:

[root@fra-01:~] find /vmfs/ -iname *.vmx

/vmfs/volumes/5c59735c-a30f6d20-cb3b-ac1f6b6c17e6/fra-01.gw.net.domain-01.net/fra-01.gw.net.domain-01.net.vmx

/vmfs/volumes/5c59735c-a30f6d20-cb3b-ac1f6b6c17e6/bit.domain-02.net/bit.domain-02.net.vmx

/vmfs/volumes/5c59735c-a30f6d20-cb3b-ac1f6b6c17e6/web-01.domain-04.net/web-01.domain-04.net.vmx

/vmfs/volumes/5c59735c-a30f6d20-cb3b-ac1f6b6c17e6/vmug-esx-01.demo.lab/vmug-esx-01.demo.lab.vmx

/vmfs/volumes/5c59735c-a30f6d20-cb3b-ac1f6b6c17e6/vmug-esx-02.demo.lab/vmug-esx-02.demo.lab.vmx

/vmfs/volumes/5c5a0645-6127d55c-25b1-ac1f6b6c17e6/ad.demo.lab/ad.demo.lab.vmx

/vmfs/volumes/5c5a0645-6127d55c-25b1-ac1f6b6c17e6/vmug-vc-01.demo.lab/vmug-vc-01.demo.lab.vmx

/vmfs/volumes/5c5a0645-6127d55c-25b1-ac1f6b6c17e6/vmug-nsx-01.demo.lab/vmug-nsx-01.demo.lab.vmx

/vmfs/volumes/5c5a0645-6127d55c-25b1-ac1f6b6c17e6/logs.demo.lab/logs.demo.lab.vmx

/vmfs/volumes/5c5a0645-6127d55c-25b1-ac1f6b6c17e6/mail.domain-03.net/mail.domain-03.net.vmx

/vmfs/volumes/5c5a0645-6127d55c-25b1-ac1f6b6c17e6/mail-01.domain-04.net/mail-01.domain-04.net.vmx

/vmfs/volumes/5c5a0645-6127d55c-25b1-ac1f6b6c17e6/psc-01a.demo.lab/psc-01a.demo.lab.vmx

/vmfs/volumes/5c5a0645-6127d55c-25b1-ac1f6b6c17e6/web.domain-03.net/web.domain-03.net.vmx

/vmfs/volumes/5c5a0645-6127d55c-25b1-ac1f6b6c17e6/psc-01b.demo.lab/psc-01b.demo.lab.vmx

/vmfs/volumes/5c5a0645-6127d55c-25b1-ac1f6b6c17e6/vcsa-01a.demo.lab/vcsa-01a.demo.lab.vmx

/vmfs/volumes/5c5a0645-6127d55c-25b1-ac1f6b6c17e6/vcsa-02a.demo.lab/vcsa-02a.demo.lab.vmx

/vmfs/volumes/5c5a0645-6127d55c-25b1-ac1f6b6c17e6/vcsa-01b.demo.lab/vcsa-01b.demo.lab.vmx

/vmfs/volumes/5c5a0645-6127d55c-25b1-ac1f6b6c17e6/vcsa-02b.demo.lab/vcsa-02b.demo.lab.vmx

/vmfs/volumes/5c5a0645-6127d55c-25b1-ac1f6b6c17e6/psc-01a-new.demo.lab/psc-01a-new.demo.lab.vmx

/vmfs/volumes/5c5a0645-6127d55c-25b1-ac1f6b6c17e6/psc-01b-new.demo.lab/psc-01b-new.demo.lab.vmx

/vmfs/volumes/5c5a0645-6127d55c-25b1-ac1f6b6c17e6/vcsa-01a-new.demo.lab/vcsa-01a-new.demo.lab.vmx

/vmfs/volumes/5c5a0645-6127d55c-25b1-ac1f6b6c17e6/vcsa-02a-new.demo.lab/vcsa-02a-new.demo.lab.vmx

/vmfs/volumes/5c5a0645-6127d55c-25b1-ac1f6b6c17e6/vcsa-01b-new.demo.lab/vcsa-01b-new.demo.lab.vmx

/vmfs/volumes/5c5a0645-6127d55c-25b1-ac1f6b6c17e6/vcsa-02b-new.demo.lab/vcsa-02b-new.demo.lab.vmx

[root@fra-01:~]

And then you should be able to map the UUID of the storage to the DS Name:

[root@fra-01:~] ls -l /vmfs/volumes/

total 3072

drwxr-xr-x    1 root     root             8 Jan  1  1970 391ff37e-e94acc5c-b2fc-7ca39819a7b7

drwxr-xr-x    1 root     root             8 Jan  1  1970 5c589eb9-b72ac2e8-d9ae-ac1f6b6c17e6

drwxr-xr-x    1 root     root             8 Jan  1  1970 5c589ec0-87bbfb24-f6f0-ac1f6b6c17e6

drwxr-xr-t    1 root     root         77824 Mar 31 22:58 5c59735c-a30f6d20-cb3b-ac1f6b6c17e6

drwxr-xr-t    1 root     root         77824 Apr  2 16:24 5c5a0645-6127d55c-25b1-ac1f6b6c17e6

drwxr-xr-x    1 root     root             8 Jan  1  1970 6172a776-c49cbba1-f4fc-a3306a0a4c17

lrwxr-xr-x    1 root     root            35 Apr  4 12:03 HDD -> 5c5a0645-6127d55c-25b1-ac1f6b6c17e6

lrwxr-xr-x    1 root     root            35 Apr  4 12:03 SSD -> 5c59735c-a30f6d20-cb3b-ac1f6b6c17e6

0 Kudos
ryanrpatel
Enthusiast
Enthusiast

Here's a snippet of a script I wrote that will scan all Datastores for vmx files and register the VM. I can send you the entire script if find it useful.

foreach($Datastore in $Datastores) {

# Searches for .VMX Files in datastore variable

$ds = Get-Datastore -Name $Datastore | %{Get-View $_.Id}

$SearchSpec = New-Object VMware.Vim.HostDatastoreBrowserSearchSpec

$SearchSpec.matchpattern = "*.vmx"

$dsBrowser = Get-View $ds.browser

$DatastorePath = "[" + $ds.Summary.Name + "]"

# Find all .VMX file paths in Datastore variable and filters out .snapshot

$SearchResult = $dsBrowser.SearchDatastoreSubFolders($DatastorePath, $SearchSpec) | where {$_.FolderPath -notmatch ".snapshot"} | %{$_.FolderPath + ($_.File | select Path).Path}

# Register all .VMX files with vCenter

foreach($VMXFile in $SearchResult) {

New-VM -VMFilePath $VMXFile -VMHost $ESXHost -Location $VMFolder -RunAsync

}

}

0 Kudos
pbalderos
Enthusiast
Enthusiast

Thanks guys!

After running the command find /vmfs/ -iname *.vmx I was still unable to locate the vm. So, I decided to go and restore the vm from backup and I noticed that the virtual machines files names were completely different that the actual virtual machine. So, at some point that server had a different name. Long story short I was able to find the actual server and re associate the vmx file to a host. All is well now. Thank you guys for the assistance and advice.

Phillip Balderos VCP6-DCV
0 Kudos
Matthew6411
Contributor
Contributor

Can you find it in the inventory by browsing it? I mean not over serach but browsing to it?

I had a similar issue: I could not find the VM with the search option but could find it by browsing the inventory. It turned out to be a missing folder path entry. I moved the VM to the root folder, then back to the correct one. The path was added and the VM was findable over search.

0 Kudos