Hyper-V force shutdown VM

Let’s face it, sometimes a Hyper-V gets stuck in a funny state and you can’t shut it down from the UI. Fear not, you can easily force it down using powershell.

Firstly, get the guid of the VM.

$VMID = (Get-VM '<name of the VM from the hyper-v manager (or Get-VM)').id

Then, find the process that’s running that VM.

$VMProcess = (Get-WMIObject Win32_Process | ? {$_.Name -match 'VMWP' -and $_.CommandLine -match $VMID})

Then you can force stop that process.

Stop-Process ($VMProcess.ProcessId) –Force

Hey presto, the VM should be down.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Navigation