Merge pull request #7101 from mwrock/generation

only specify Hyper-V generation if the parameter is supported
This commit is contained in:
Seth Vargo 2016-03-07 10:57:21 -05:00
commit 77a090395a
1 changed files with 5 additions and 1 deletions

View File

@ -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