Skip to content

Instantly share code, notes, and snippets.

@mttaggart
Created May 1, 2022 05:42
Show Gist options
  • Save mttaggart/1f3c0e517fab3d30924aa413ce704527 to your computer and use it in GitHub Desktop.
Save mttaggart/1f3c0e517fab3d30924aa413ce704527 to your computer and use it in GitHub Desktop.
Force Stop VM
# Usage: As admin:
# .\Stop-VM.ps1 "My VM Name"
$id = Get-VM $args[0] | select Id
$VMWMProc = (Get-WMIObject Win32_Process | ? {$_.Name -match 'VMWP' -and $_.CommandLine -match $id })
Stop-Process ($VMWMProc.ProcessId) -Force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment