support/hyperv.ps1 in kitchen-hyperv-0.1.9 vs support/hyperv.ps1 in kitchen-hyperv-0.1.10
- old
+ new
@@ -1,16 +1,16 @@
#requires -Version 2 -Modules Hyper-V
#implicitly import hyperv module to avoid powercli cmdlets
-if((Get-Module -Name hyperv) -ne $null)
+if((Get-Module -Name 'hyper-v') -ne $null)
{
- Remove-Module -Name hyperv
- Import-Module -Name hyperv
+ Remove-Module -Name hyper-v
+ Import-Module -Name hyper-v
}
else
{
- Import-Module -Name hyperv
+ Import-Module -Name hyper-v
}
$ProgressPreference = 'SilentlyContinue'
@@ -82,11 +82,11 @@
$vm | Set-VMMemory -DynamicMemoryEnabled $true -MinimumBytes $DynamicMemoryMinBytes -MaximumBytes $DynamicMemoryMaxBytes
}
else {
$vm | Set-VMMemory -DynamicMemoryEnabled $false
}
-
+
$vm | Start-Vm -passthru |
foreach {
$vm = $_
do {
start-sleep -seconds 2
@@ -115,21 +115,21 @@
[String[]]$IPAddress = @(),
[String[]]$Subnet = @()
)
$vm = Get-WmiObject -Namespace 'root\virtualization\v2' -Class 'Msvm_ComputerSystem' | Where-Object {
- $_.ElementName -eq $NetworkAdapter.VMName
+ $_.ElementName -eq $NetworkAdapter.VMName
}
$VMSettings = $vm.GetRelated('Msvm_VirtualSystemSettingData') | Where-Object {
- $_.VirtualSystemType -eq 'Microsoft:Hyper-V:System:Realized'
+ $_.VirtualSystemType -eq 'Microsoft:Hyper-V:System:Realized'
}
$VMNetAdapters = $VMSettings.GetRelated('Msvm_SyntheticEthernetPortSettingData')
$NetworkSettings = @()
- foreach ($NetAdapter in $VMNetAdapters)
+ foreach ($NetAdapter in $VMNetAdapters)
{
- if ($NetAdapter.Address -eq $NetworkAdapter.MacAddress)
+ if ($NetAdapter.Address -eq $NetworkAdapter.MacAddress)
{
$NetworkSettings = $NetworkSettings + $NetAdapter.GetRelated('Msvm_GuestNetworkAdapterConfiguration')
}
}
@@ -140,21 +140,21 @@
$Service = Get-WmiObject -Class 'Msvm_VirtualSystemManagementService' -Namespace 'root\virtualization\v2'
$setIP = $Service.SetGuestNetworkAdapterConfiguration($vm, $NetworkSettings[0].GetText(1))
- if ($setIP.ReturnValue -eq 4096)
+ if ($setIP.ReturnValue -eq 4096)
{
$job = [WMI]$setIP.job
- while ($job.JobState -eq 3 -or $job.JobState -eq 4)
+ while ($job.JobState -eq 3 -or $job.JobState -eq 4)
{
Start-Sleep 1
$job = [WMI]$setIP.job
}
- if ($job.JobState -ne 7)
+ if ($job.JobState -ne 7)
{
$job.GetError()
}
}
(Get-VM -Id $NetworkAdapter.VmId).NetworkAdapter | Select-Object Name, IpAddress
@@ -166,11 +166,11 @@
param($Id)
Get-VM -Id $Id |
ForEach-Object {
$vm = $_
- do
+ do
{
Start-Sleep -Seconds 1
}
while (-not (Get-VmIP $vm))
@@ -187,10 +187,10 @@
Get-VMSwitch |
Select-Object -First 1 |
Select-Object Name, Id
}
-function Mount-VMISO
+function Mount-VMISO
{
[cmdletbinding()]
param($Id, $Path)
set-VMDvdDrive -VMName (Get-VM -Id $Id).Name -Path $Path