Little bit of cleanup.
This commit is contained in:
parent
e6093dd709
commit
37a525fbbc
|
@ -22,7 +22,6 @@
|
||||||
$Dir = Split-Path $script:MyInvocation.MyCommand.Path
|
$Dir = Split-Path $script:MyInvocation.MyCommand.Path
|
||||||
. ([System.IO.Path]::Combine($Dir, "utils\write_messages.ps1"))
|
. ([System.IO.Path]::Combine($Dir, "utils\write_messages.ps1"))
|
||||||
|
|
||||||
# load the config from the vmcx and make a copy for editing, use TMP path so we are sure there is no vhd at the destination
|
|
||||||
$VmProperties = @{
|
$VmProperties = @{
|
||||||
Path = $vm_config_file
|
Path = $vm_config_file
|
||||||
SnapshotFilePath = Join-Path $data_path 'Snapshots'
|
SnapshotFilePath = Join-Path $data_path 'Snapshots'
|
||||||
|
@ -32,7 +31,6 @@ $VmProperties = @{
|
||||||
|
|
||||||
$vmConfig = (Compare-VM -Copy -GenerateNewID @VmProperties)
|
$vmConfig = (Compare-VM -Copy -GenerateNewID @VmProperties)
|
||||||
|
|
||||||
|
|
||||||
$generation = $vmConfig.VM.Generation
|
$generation = $vmConfig.VM.Generation
|
||||||
|
|
||||||
if (!$vmname) {
|
if (!$vmname) {
|
||||||
|
@ -67,19 +65,16 @@ if (!$memory) {
|
||||||
$configMemory = Get-VMMemory -VM $vmConfig.VM
|
$configMemory = Get-VMMemory -VM $vmConfig.VM
|
||||||
$dynamicmemory = $configMemory.DynamicMemoryEnabled
|
$dynamicmemory = $configMemory.DynamicMemoryEnabled
|
||||||
|
|
||||||
# Memory values need to be in bytes
|
|
||||||
$MemoryMaximumBytes = ($configMemory.Maximum)
|
$MemoryMaximumBytes = ($configMemory.Maximum)
|
||||||
$MemoryStartupBytes = ($configMemory.Startup)
|
$MemoryStartupBytes = ($configMemory.Startup)
|
||||||
$MemoryMinimumBytes = ($configMemory.Minimum)
|
$MemoryMinimumBytes = ($configMemory.Minimum)
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (!$maxmemory){
|
if (!$maxmemory){
|
||||||
$dynamicmemory = $False
|
$dynamicmemory = $False
|
||||||
$MemoryMaximumBytes = ($memory -as [int]) * 1MB
|
$MemoryMaximumBytes = ($memory -as [int]) * 1MB
|
||||||
$MemoryStartupBytes = ($memory -as [int]) * 1MB
|
$MemoryStartupBytes = ($memory -as [int]) * 1MB
|
||||||
$MemoryMinimumBytes = ($memory -as [int]) * 1MB
|
$MemoryMinimumBytes = ($memory -as [int]) * 1MB
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$dynamicmemory = $True
|
$dynamicmemory = $True
|
||||||
$MemoryMaximumBytes = ($maxmemory -as [int]) * 1MB
|
$MemoryMaximumBytes = ($maxmemory -as [int]) * 1MB
|
||||||
$MemoryStartupBytes = ($memory -as [int]) * 1MB
|
$MemoryStartupBytes = ($memory -as [int]) * 1MB
|
||||||
|
@ -87,12 +82,10 @@ else {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!$switchname) {
|
if (!$switchname) {
|
||||||
$switchname = (Get-VMNetworkAdapter -VM $vmConfig.VM).SwitchName
|
$switchname = (Get-VMNetworkAdapter -VM $vmConfig.VM).SwitchName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Connect-VMNetworkAdapter -VMNetworkAdapter (Get-VMNetworkAdapter -VM $vmConfig.VM) -SwitchName $switchname
|
Connect-VMNetworkAdapter -VMNetworkAdapter (Get-VMNetworkAdapter -VM $vmConfig.VM) -SwitchName $switchname
|
||||||
Set-VM -VM $vmConfig.VM -NewVMName $vm_name -MemoryStartupBytes $MemoryStartupBytes
|
Set-VM -VM $vmConfig.VM -NewVMName $vm_name -MemoryStartupBytes $MemoryStartupBytes
|
||||||
Set-VM -VM $vmConfig.VM -ErrorAction "Stop" -ProcessorCount $processors
|
Set-VM -VM $vmConfig.VM -ErrorAction "Stop" -ProcessorCount $processors
|
||||||
|
@ -123,13 +116,12 @@ if ($generation -ne 1) {
|
||||||
|
|
||||||
$report = Compare-VM -CompatibilityReport $vmConfig
|
$report = Compare-VM -CompatibilityReport $vmConfig
|
||||||
|
|
||||||
# Stop if there is incompatibilities which would fail anyhow.
|
# Stop if there are incompatibilities
|
||||||
if($report.Incompatibilities.Length -gt 0){
|
if($report.Incompatibilities.Length -gt 0){
|
||||||
Write-Error-Message $(ConvertTo-Json $($report.Incompatibilities | Select -ExpandProperty Message))
|
Write-Error-Message $(ConvertTo-Json $($report.Incompatibilities | Select -ExpandProperty Message))
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Differencing disk
|
|
||||||
if($differencing_disk){
|
if($differencing_disk){
|
||||||
# Get all controller on the VM, first scsi, then IDE if it is a Gen 1 device
|
# Get all controller on the VM, first scsi, then IDE if it is a Gen 1 device
|
||||||
$controllers = Get-VMScsiController -VM $vmConfig.VM
|
$controllers = Get-VMScsiController -VM $vmConfig.VM
|
||||||
|
@ -148,7 +140,6 @@ if($differencing_disk){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Import-VM -CompatibilityReport $vmConfig
|
Import-VM -CompatibilityReport $vmConfig
|
||||||
|
|
Loading…
Reference in New Issue