Add check if EnhancedSessionTransportType is supported by the current version of HyperV

This commit is contained in:
RudiMT 2021-03-02 20:43:08 +01:00 committed by sophia
parent 740b1bcabe
commit 0867fbd9d8

View File

@ -17,8 +17,14 @@ try {
}
try {
Hyper-V\Set-VM -VM $VM -EnhancedSessionTransportType $Type
# HyperV 1.1 (Windows Server 2012R2) crashes on this call. Vagrantfiles before 2.2.10 do break without skipping this.
$present = Get-Command Hyper-V\Set-VM -ParameterName EnhancedSessionTransportType -ErrorAction SilentlyContinue
if($present) {
Hyper-V\Set-VM -VM $VM -EnhancedSessionTransportType $Type
}else{
Write-OutputMessage "This version of HyperV does not support EnhancedSessionTransportType, ignoring."
}
} catch {
Write-ErrorMessage "Failed to assign EnhancedSessionTransportType to ${Type}: ${PSItem}"
Write-ErrorMessage "Failed to assign EnhancedSessionTransportType to ${Type}:${PSItem}"
exit 1
}