Skip to content

Commit

Permalink
Streamlined Save-LabVm function
Browse files Browse the repository at this point in the history
  • Loading branch information
nyanhp committed Sep 17, 2018
1 parent 97fd9e5 commit 4642b0e
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions AutomatedLab/AutomatedLabVirtualMachines.psm1
Expand Up @@ -401,25 +401,15 @@ function Save-LabVM
Write-ScreenInfo 'There is no machine to start' -Type Warning
return
}

foreach ($vm in $vms)

Write-Verbose -Message "Saving VMs '$($vms -join ',')"
switch ($lab.DefaultVirtualizationEngine)
{
Write-Verbose "Saving VMs '$vm'"

if ($vm.HostType -eq 'HyperV')
{
Save-LWHypervVM -ComputerName $vm
}
elseif ($vm.HostType -eq 'Azure')
{
Write-Error 'Azure does not support saving machines'
}
elseif ($vm.HostType -eq 'VMWare')
{
Save-LWVMWareVM -ComputerName $vm
}
'HyperV' { Save-LWHypervVM -ComputerName $vms}
'VMWare' { Save-LWVMWareVM -ComputerName $vms}
'Azure' { Write-Warning -Message "Skipping Azure VMs '$($vms -join ',')' as suspending the VMs is not supported on Azure."}
}

Write-LogFunctionExit
}
}
Expand Down

0 comments on commit 4642b0e

Please sign in to comment.