Working as a small business often brings you little tasks here and there. Today I've decided to shut down the Hyper-V machine to expand its disks. Unfortunately for me, while extending of HDD went great, I couldn't start Virtual Machine any longer.
I knew something was up when during day Status for almost all Hyper-V machines was showing Backing up… but I did try to start it up anyways. Unfortunately, the error made it apparent that I have more things to do before I can proceed with my day.
The application encountered an error while attempting to change the state of AD1. AD1 failed to change state. The operation cannot be performed while the object is in its current state.
In such a case, there are two things you can do. Reboot your Hyper-V server which will most likely fix it but will leave you in a bad feeling as you shouldn't fix issues by rebooting servers, or fix it which often requires a bit of additional work.
This problem can be fixed by restarting Hyper-V Virtual Machine Management service. It's fairly safe operation and I never had problems doing so. When you stop that service you will be unable to manage Hyper-V.
There are of course two ways to do it – standard and PowerShell way. I wouldn't be myself if I wouldn't try to fix it with PowerShell even thou I knew, in this case, it most likely took more time to type all commands but I do that to enhance my PowerShell memory.
PS C:\Windows\system32> Get-Process | Where-Object { $_.Name -like '*vm*' } Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName ------- ------ ----- ----- ----- ------ -- ----------- 853 46 64920 26748 203 ...60,51 2236 vmms 964 67 18488 5032 190 6 665,33 3600 vmwp 847 62 11572 7160 153 438,58 4212 vmwp 723 64 16884 5088 188 479,36 4224 vmwp 903 65 16032 4840 172 286,20 4464 vmwp 601 65 11756 7148 157 475,37 8828 vmwp PS C:\Windows\system32> Get-Process | Where-Object { $_.ProcessName -eq 'vmms' } | Stop-Process Confirm Are you sure you want to perform the Stop-Process operation on the following item: vmms(2236)? [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): y PS C:\Windows\system32> Start-Service VMMS PS C:\Windows\system32>
As you can notice above I've made a small mistake and instead of using Restart-Service I went ahead and killed the process. It's useful if you ever have a service which doesn't want to be stopped you can do so by killing its process. Usually, you would first try and restart service using graceful way.
Get-Service vmms | Restart-Service
Via GUI you would press Start, type services.msc and find Hyper-V Virtual Machine Management and restart it.
After that, all right click actions are back again, and I was able to start the machine.