vagrant/plugins/providers/hyperv/scripts/stop_vm.ps1

18 lines
355 B
PowerShell

#Requires -Modules VagrantMessages
Param(
[Parameter(Mandatory=$true)]
[string]$VmId
)
$ErrorActionPreference = "Stop"
try{
# Shuts down virtual machine regardless of any unsaved application data
$VM = Hyper-V\Get-VM -Id $VmId
Hyper-V\Stop-VM $VM -Force
} catch {
Write-Error-Message "Failed to stop VM: ${PSItem}"
exit 1
}