Same result. Here's my current code:
try
{
Stop-VM -VM $vmName -Confirm:$false
while ($vmName.PowerState -eq "PoweredOn") {start-sleep -seconds 3}
}
catch [Exception]
{
$m += "Error stopping the VM: " + $_ + "`r`n"
logError $m
continue
}
$m += "Removing " + $vmName + "`r`n"
try
{
Remove-VM -VM $vmName -DeletePermanently -Confirm:$false
}
catch [Exception]
{
$m += "Error removing the VM: " + $_ + "`r`n"
logError $m
continue
}