From 508492faaef2eb9aea27fc8f8e3e74410da16882 Mon Sep 17 00:00:00 2001 From: Matt Wrock Date: Fri, 4 Mar 2016 23:42:17 -0800 Subject: [PATCH] fixes #7098 only specifying Hyper-V generation if the parameter is supported --- plugins/providers/hyperv/scripts/import_vm.ps1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/providers/hyperv/scripts/import_vm.ps1 b/plugins/providers/hyperv/scripts/import_vm.ps1 index a994c1cfb..7232be56d 100644 --- a/plugins/providers/hyperv/scripts/import_vm.ps1 +++ b/plugins/providers/hyperv/scripts/import_vm.ps1 @@ -107,7 +107,6 @@ $secure_boot_enabled = (Select-Xml -xml $vmconfig -XPath "//secure_boot_enabled" $vm_params = @{ Name = $vm_name - Generation = $generation NoVHD = $True MemoryStartupBytes = $MemoryStartupBytes SwitchName = $switchname @@ -115,6 +114,11 @@ $vm_params = @{ ErrorAction = "Stop" } +# Generation parameter was added in ps v4 +if((get-command New-VM).Parameters.Keys.Contains("generation")) { + $vm_params.Generation = $generation +} + # Create the VM using the values in the hash map $vm = New-VM @vm_params