@@ -100,6 +100,13 @@ function Move-SCVirtualMachineReliably {
100100 Write-Debug - Message (' $DestinationVMHost.ServerConnection.ManagedComputer.ID: '' {0}'' ' -f [string ]$DestinationVMHost.ServerConnection.ManagedComputer.ID )
101101 Write-Debug - Message ' if ($SourceVMHost.ServerConnection.ManagedComputer.ID -eq $DestinationVMHost.ServerConnection.ManagedComputer.ID)'
102102 if ($SourceVMHost.ServerConnection.ManagedComputer.ID -eq $DestinationVMHost.ServerConnection.ManagedComputer.ID ) {
103+
104+ Write-Debug - Message ' Read-SCVMHosts -VMHost ($SourceVMHost, $DestinationVMHost)'
105+ Read-SCVMHosts - VMHost ($SourceVMHost , $DestinationVMHost )
106+
107+ Write-Debug - Message ' Repair-SCVMMigrationFailed -VMHost ($SourceVMHost, $DestinationVMHost)'
108+ Repair-SCVMMigrationFailed - VMHost ($SourceVMHost , $DestinationVMHost )
109+
103110 Write-Debug - Message ' if (-not $VM)'
104111 if (-not $VM ) {
105112 Write-Debug - Message ' $VM = Get-SCVirtualMachine -VMHost $SourceVMHost'
@@ -167,9 +174,6 @@ function Move-SCVirtualMachineReliably {
167174 }
168175 Write-Debug - Message (' $Filter = {{{0}}}' -f $Filter )
169176
170- Write-Debug - Message ' Read-SCVMHosts -VMHost ($SourceVMHost, $DestinationVMHost)'
171- Read-SCVMHosts - VMHost ($SourceVMHost , $DestinationVMHost )
172-
173177 Write-Debug - Message (' $SourceSCVMs = Get-SCVirtualMachine -VMHost $SourceVMHost | Where-Object -FilterScript {{{0}}}' -f $Filter )
174178 $SourceSCVMs = Get-SCVirtualMachine - VMHost $SourceVMHost | Where-Object - FilterScript $Filter # Getting those VMs of which we care about
175179 Write-Debug - Message (' $SourceSCVMs: '' {0}'' ' -f [string ]$SourceSCVMs.Name )
@@ -287,6 +291,10 @@ function Move-SCVirtualMachineReliably {
287291 Write-Debug - Message ' if ($CurrentLiveMigrationCount -lt $LiveMigrationMaximum)'
288292 if ($CurrentLiveMigrationCount -lt $LiveMigrationMaximum ) {
289293 # If the migration queue is not full (if it is full, we do no care who filled it up)
294+
295+ Write-Debug - Message ' $SCVM = Read-SCVirtualMachine -VM $SCVM'
296+ $SCVM = Read-SCVirtualMachine - VM $SCVM
297+
290298 $SCVirtualMachineLiveMigrationEligibility = Test-SCVirtualMachineLiveMigrationEligibility - VM $SCVM - VMHost $DestinationVMHost
291299 Write-Debug - Message (' $SCVirtualMachineLiveMigrationEligibility.Result: '' {0}'' ' -f $SCVirtualMachineLiveMigrationEligibility.Result )
292300 Write-Debug - Message (' $SCVirtualMachineLiveMigrationEligibility.Reason: '' {0}'' ' -f $SCVirtualMachineLiveMigrationEligibility.Reason )
@@ -350,8 +358,13 @@ function Move-SCVirtualMachineReliably {
350358 catch {
351359 Write-Debug - Message ($_ )
352360 Write-Debug - Message (' Exception.HResult: {0}' -f $_.Exception.HResult )
361+ Write-Debug - Message (' $SCVM.Status: '' {0}'' ' -f [string ]$SCVM.Status )
362+ Write-Debug - Message (' $SCVM.VMHost: '' {0}'' ' -f [string ]$SCVM.VMHost )
363+ Write-Debug - Message ' Repair-SCVMMigrationFailed -VMHost $SCVM.VMHost'
364+ Repair-SCVMMigrationFailed - VMHost $SCVM.VMHost
353365 Write-Debug - Message ' $null = Read-SCVirtualMachine -VM $SCVM'
354366 $null = Read-SCVirtualMachine - VM $SCVM
367+ Write-Debug - Message (' $SCVM.Status: '' {0}'' ' -f [string ]$SCVM.Status )
355368 Write-Debug - Message ' Continue'
356369 Continue
357370 }
@@ -541,6 +554,9 @@ function Move-SCVirtualMachineReliably {
541554 }
542555 }
543556
557+ Write-Debug - Message ' Repair-SCVMMigrationFailed -VMHost ($SourceVMHost, $DestinationVMHost)'
558+ Repair-SCVMMigrationFailed - VMHost ($SourceVMHost , $DestinationVMHost )
559+
544560 Write-Debug - Message (' $SourceSCVMs: '' {0}'' ' -f [string ]$SourceSCVMs.Name )
545561 Write-Debug - Message ' while ($SourceSCVMs)'
546562 }
0 commit comments