support/hyperv.ps1 in kitchen-hyperv-0.2.3 vs support/hyperv.ps1 in kitchen-hyperv-0.3.0

- old
+ new

@@ -74,18 +74,21 @@ $SwitchName, $ProcessorCount, $UseDynamicMemory, $DynamicMemoryMinBytes, $DynamicMemoryMaxBytes, - $boot_iso_path + $boot_iso_path, + $EnableGuestServices ) $null = $psboundparameters.remove('ProcessorCount') $null = $psboundparameters.remove('UseDynamicMemory') $null = $psboundparameters.remove('DynamicMemoryMinBytes') $null = $psboundparameters.remove('DynamicMemoryMaxBytes') $null = $psboundparameters.remove('boot_iso_path') + $null = $psboundparameters.remove('EnableGuestServices') $UseDynamicMemory = [Convert]::ToBoolean($UseDynamicMemory) + $null = [bool]::TryParse($EnableGuestServices,[ref]$EnableGuestServices) $vm = new-vm @psboundparameters | Set-Vm -ProcessorCount $ProcessorCount -passthru if ($UseDynamicMemory) { $vm | Set-VMMemory -DynamicMemoryEnabled $true -MinimumBytes $DynamicMemoryMinBytes -MaximumBytes $DynamicMemoryMaxBytes @@ -94,10 +97,13 @@ $vm | Set-VMMemory -DynamicMemoryEnabled $false } if (-not [string]::IsNullOrEmpty($boot_iso_path)) { Mount-VMISO -Id $vm.Id -Path $boot_iso_path } + if ($EnableGuestServices -and (Get-command Enable-VMIntegrationService -ErrorAction SilentlyContinue)) { + Enable-VMIntegrationService -VM $vm -Name 'Guest Service Interface' + } $vm | Start-Vm -passthru | foreach { $vm = $_ do { start-sleep -seconds 2 @@ -209,7 +215,13 @@ function Mount-VMISO { [cmdletbinding()] param($Id, $Path) - set-VMDvdDrive -VMName (Get-VM -Id $Id).Name -Path $Path + if ((Get-VM -Id $Id).Generation -eq 2) + { + Add-VMDvdDrive (Get-VM -Id $Id).Name | Set-VMDvdDrive -VMName (Get-VM -Id $Id).Name -Path $Path + } + + Set-VMDvdDrive -VMName (Get-VM -Id $Id).Name -Path $Path } +