I was trying to bring an ESX host to maintenance mode, but it keep failing to migrate a box using vMotion. Being that VM the only one left, I suspended it and migrated it manually. Everything worked ok.
When I came back to that box to power it on again, this error showed up:
This virtual machine cannot be powered on because its working directory is not valid. Use the configuration editor to set a valid working directory, and then try again.
Reading the not valid working directory, I proceeded to remove from inventory the VM so I can add it again manually registering the vmx file, only when I opened the datastore the folder for that VM was empty. Enter the WTF.
I've tried refreshing everything but the result was the same everytime I browsed the datastore. So finally I opened a new vClient for the specific ESX host, opened the datastore and there they were, all the files for that VM. "Everthing's good now" I thought ingeniously.
I tried to register the vmx but suddenly the same error popped up. This time I found this KB article from VMware:
Specially where it says that this issue may occur if the name of the virtual machine directory has a space at the beginning or the end of the directory name. You may also experience problems powering on a virtual machine if there are spaces in the virtual machine disk’s name.
I've doublechecked and bingo! There was a space at the end of the folder name. I fixed that and vmx was registered with no further problems.