Convert-VHD : Hyper-V encountered an error trying to access an object on computer ‘…’ because the object was not found.

In recent tutorial I covered command that I’m often using – “Convert-VHD”, but some time ago I had to run it from a PC which I’m not using and it gave me a huge headache, so lets go step by step and resolve issues with Convert-VHD.

These steps will also help if you are not able to connect to localhost in Hyper-V.

First after I entered full Convert-VHD command into Powershell, I got following error:

“The term ‘Convert-VHD’ is not recognized as the name of a cmdlet, function, script file, or operable program. Chec…”

So, I thought, what the heck is this? Ok, machine didn’t have installed Hyper-V :D 

Control Panel | Programs And Features | choose “Turn Windows Features on or off” from the left side of the screen | Select all options under Hyper-V, confirm installation, install and reboot.

After reboot – same issue from Powershell. I started Powershell ISE (run as Admin), from the right side of the screen I entered “Convert” in the name field. It offered Convert-VHD command – I selected it – confirmed with Show details (then module Convert-VHD got imported), and then I was able to use Convert-VHD command.

Convert-VHD : Hyper-V encountered an error trying to access an object on computer ‘YourComputerName’ because the object was not found. The object might have been deleted. Verify that the Virtual Machine Management service on the computer is running.

At line:1 char:1

+ Convert-VHD -DestinationPath C:\temp\WindowsServer2012R2DTCNTNew.vhd  …

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : ObjectNotFound: (:) [Convert-VHD], VirtualizationException

    + FullyQualifiedErrorId : ObjectNotFound,Microsoft.Vhd.PowerShell.Cmdlets.ConvertVhd

Ok, first I went and checked Hyper-V virtual machine management – it wasn’t running. I started it, but still – same error.

Research some more… I found following command and I run it through command prompt (as admin)

MOFCOMP %SYSTEMROOT%\System32\WindowsVirtualization.V2.mof

Command was success, but still no luck, same error.

Finally, I checked one more thing. 

Go to Search, and type in – Windows Security

In Windows Security select App & Browser Control | scroll down to the bottom of the screen and select Exploit protection settings | then you will see screen pictured below – switch to Program settings | locate C:\Windows\system32\vmcompute.exe, expand it and select Edit

Find Control Flow Guide (CFG) and DESELECT Override system settings.

You can now close all the settings.

Run Powershell (as admin) and enter following command

net start vmcompute

Then… I tried Convert-VHD and it worked!!!

This will also repair error (second one) in which Hyper-V Manager doesn’t see your localhost.

Disclaimer