Created
May 1, 2022 05:42
-
-
Save mttaggart/1f3c0e517fab3d30924aa413ce704527 to your computer and use it in GitHub Desktop.
Force Stop VM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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