Skip to content

Instantly share code, notes, and snippets.

@viceice
Created March 24, 2023 08:19
Show Gist options
  • Save viceice/9560b2972ad1fa6a924779e36fdaf84a to your computer and use it in GitHub Desktop.
Save viceice/9560b2972ad1fa6a924779e36fdaf84a to your computer and use it in GitHub Desktop.
HyperV: Delete a failed planned VM
param(
[Parameter(Mandatory)]
[string]$Name
)
$vmms = Get-WmiObject -Namespace root\virtualization\v2 -Class Msvm_VirtualSystemManagementService
$pvm = Get-WmiObject -Namespace root\virtualization\v2 -Query "Select * From Msvm_PlannedComputerSystem where elementname='${Name}'"
$vmms.DestroySystem($pvm)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment