Welcome to deBUG.to Community where you can ask questions and receive answers from Microsoft MVPs and other experts in our community.
0 like 0 dislike
7.2k views
in Windows by 2 2 4
edited by

I created a virtual machine from a hard disk image file (vhdx) using Hyper-V, it's created successfully but when connecting to the virtual machine It's not working and I got this error message

The application encountered an error while attempting to change the state virtual machine
New Virtual Machine failed to change state.
The operation cannot be performed while the object is in use.

virtual machine failed to change state

I have free disk space and memory, I still getting virtual machine failed to change state

by
0 0
I encountered the same problem and this post helped me to get it solved, Thanks!

1 Answer

1 like 0 dislike
by 159 186 375
selected by
 
Best answer

Virtual Machine failed to change state

Actually, this error "The operation cannot be performed while the object is in use" is not related to no free hard disk space or sufficient memory. it's mainly related to the hard disk image file that you have used when creating your virtual machine!

Fixing The application encountered an error while attempting to change the state

This error usually occurs in case you have tried to mount the virtual hard disk image file VHDX or you have double-clicked on it by mistake.

mount hard disk image file vhdx-min

In this case, the virtual hard disk image file will be attached to the disk of the host server and this will lead to being in use.

Detach Virtual Hard Disk Steps

To be able to use the virtual hard disk file and avoid the "Virtual Machine failed to change state, the object in use" error when starting Virtual Machine using Hyper-V, you should first detach the virtual hard disk from disk management by doing the following:

  • Using Administrator Account, Open Computer Management.
    open computer management in windows server

  • From the left side, click on Storage > Disk Management.
    Open Disk management in windows server

  • Check the online disks, and right-click on the last one added, if it has a Detach VHD option, so it means it's a virtual hard disk.
    detach vhd from Disk Management in Windows Server

  • Select Detach VHD, you will get a confirmation with your virtual hard disk location as shown below
    deatach vhdx from storage

  • Before clicking on OK, make sure that this the correct virtual disk file that would like to remove by matching the location path on the above message and the actual virtual hard disk file location in your host.

  • Try now to start virtual machine that should be started and working properly without showing this error "New Virtual Machine failed to change state" again.

See Also

by
1 0
Thank you, this was exactly the answer I have spent an hour looking for...(novice Win Server 2019 Hyper-V admin)
If you don’t ask, the answer is always NO!
...