Forcefully stop guestvm
Purpose¶
If you have a GuestVM that will not stop gracefully either because the Hyper-V host is goofed-up or the VMMS service won't allow you to restart it. You can perform a hail-mary to forcefully stop the GuestVM's Hyper-V process.
May Cause GuestVM to be Inconsistent
This is meant as a last-resort when there are no other options on-the-table. You may end up corrupting the GuestVM by doing this.
Get the VMID of the GuestVM¶
Get-VM SERVER-01 | Select VMName, VMId
# Example Output
# VMName VMId
# ------ ------------------------------------
# DC3 3e4b6f91-6c6c-4075-9b7e-389d46315074
Extrapolate Process ID¶
Now you need to hunt-down the process ID associated with the GuestVM.
Get-CimInstance Win32_Process -Filter "Name='vmwp.exe'" |
Where-Object { $_.CommandLine -match "3e4b6f91-6c6c-4075-9b7e-389d46315074" } |
Select-Object ProcessId, CommandLine
# Example Output
# ProcessId CommandLine
# --------- ---------------------------------------------------------
# 12488 "C:\Windows\System32\vmwp.exe" -vmid 3e4b6f91-6c6c-4075-9b7e-389d46315074
Terminate Process¶
Lastly, you terminate the process by its ID.