Skip to content

Commit a31579a

Browse files
committed
Merge branch 'vanilla-multipath-vhd-support' into 'dev'
Adds support for migrating vanilla VMs with disks from different host partitions See merge request fozzy-winadmins/AutomaticMaintenance!19
2 parents 982bc9e + db274df commit a31579a

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

AutomaticMaintenance.psm1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ $ModuleName = ($MyInvocation.MyCommand.Name).Substring(0, ($MyInvocation.MyComma
4444
[string]$ModuleWideUpdateSearchCriteria = 'IsInstalled=0 and IsHidden=0'
4545

4646
[bool]$ModuleWideHVVanillaPutInASubfolder = $true
47+
[bool]$ModuleWideHVVanillaPreserveSourceVhdPathDriveLetter = $false
4748

4849
foreach ($FunctionType in @('Private', 'Public')) {
4950
$Path = Join-Path -Path $ModulePath -ChildPath ('{0}\*.ps1' -f $FunctionType)

Private/HV-Vanilla/Clear-ComputerWorkloadHVVanilla.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ function Clear-ComputerWorkloadHVVanilla {
1515
[scriptblock]$DestinationFilter,
1616
[int]$MaxParallelMigrations,
1717
[switch]$PutInASubfolder = $ModuleWideHVVanillaPutInASubfolder,
18+
[switch]$PreserveSourceVhdPathDriveLetter = $ModuleWideHVVanillaPreserveSourceVhdPathDriveLetter,
1819
[ref]$DestinationVMHostLock
1920
)
2021

@@ -32,6 +33,7 @@ function Clear-ComputerWorkloadHVVanilla {
3233
Write-Debug -Message ('$DestinationFilter = {{{0}}}' -f $DestinationFilter)
3334
Write-Debug -Message ('$MaxParallelMigrations = {0}' -f $MaxParallelMigrations)
3435
Write-Debug -Message ('$PutInASubfolder = ${0}' -f $PutInASubfolder)
36+
Write-Debug -Message ('$PreserveSourceVhdPathDriveLetter = ${0}' -f $PreserveSourceVhdPathDriveLetter)
3537
Write-Debug -Message ('$DestinationVMHostLock: ''{0}''' -f $DestinationVMHostLock)
3638
Write-Debug -Message ('$DestinationVMHostLock.Value: ''{0}''' -f $DestinationVMHostLock.Value)
3739

@@ -91,8 +93,8 @@ function Clear-ComputerWorkloadHVVanilla {
9193
Write-Debug -Message ('$DestinationVMHost = Get-VMHost -ComputerName ''{0}''' -f $DestinationVMHostName)
9294
$DestinationVMHost = Get-VMHost -ComputerName $DestinationVMHostName
9395
Write-Debug -Message ('$DestinationVMHost: ''{0}''' -f $DestinationVMHost)
94-
Write-Debug -Message ('$UnmigratableVMs = Move-VMReliably -DestinationVMHost $DestinationVMHost -Path ''{0}'' -VM $SourceVMs -MaxParallelMigrations {1} -PutInASubfolder:${2}' -f $DestinationVMHostPath, $MaxParallelMigrations, $PutInASubfolder)
95-
$UnmigratableVMs = Move-VMReliably -DestinationVMHost $DestinationVMHost -Path $DestinationVMHostPath -VM $SourceVMs -MaxParallelMigrations $MaxParallelMigrations -PutInASubfolder:$PutInASubfolder
96+
Write-Debug -Message ('$UnmigratableVMs = Move-VMReliably -DestinationVMHost $DestinationVMHost -Path ''{0}'' -VM $SourceVMs -MaxParallelMigrations {1} -PutInASubfolder:${2} -PreserveSourceVhdPathDriveLetter:${3}' -f $DestinationVMHostPath, $MaxParallelMigrations, $PutInASubfolder, $PreserveSourceVhdPathDriveLetter)
97+
$UnmigratableVMs = Move-VMReliably -DestinationVMHost $DestinationVMHost -Path $DestinationVMHostPath -VM $SourceVMs -MaxParallelMigrations $MaxParallelMigrations -PutInASubfolder:$PutInASubfolder -PreserveSourceVhdPathDriveLetter:$PreserveSourceVhdPathDriveLetter
9698
Write-Debug -Message ('$UnmigratableVMs: ''{0}''' -f [string]$UnmigratableVMs.Name)
9799
Write-Debug -Message 'if ($UnmigratableVMs)'
98100
if ($UnmigratableVMs) {

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ There are several variables defined in the .psm1-file, which are used by the mod
125125
* `[string]$ModuleWideUpdateSearchCriteria` - Criteria for the IUpdateSearcher::Search method (<https://docs.microsoft.com/en-us/windows/desktop/api/wuapi/nf-wuapi-iupdatesearcher-search>)
126126

127127
* `[bool]$ModuleWideHVVanillaPutInASubfolder` - When set to `$true` (default), places vanilla Hyper-V virtual machines in subfolders, named as VMs themselves, therefore mimicking SCVMM behavior. Requires access to WinRM on the target computer and access to the Win32_Directory WMI class.
128+
* `[bool]$ModuleWideHVVanillaPreserveSourceVhdPathDriveLetter` - When set to `$false` (default), VHDs attached to virtual machines will be placed to the destination directory defined in the "workload" configuration block. When set to `$true`, virtual hard disks of the migrated virtual machines will be placed to the partitions with the same drive letters as on the source host, if such partitions exist.
128129

129130
## Loading variables from an external source
130131

0 commit comments

Comments
 (0)