-
-
Save webtroter/46ac85c7c1f8ee8a975d110e4925aabc to your computer and use it in GitHub Desktop.
Helper to run the merge.txt generated by "Create and run merge commands"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
This script will run the commands generated by [Create and run merge commands - How to merge checkpoints that have multiple differencing disks](https://learn.microsoft.com/en-us/troubleshoot/windows-server/virtualization/merge-checkpoints-with-many-differencing-disks#mergechain) | |
Please read the whole page from Microsoft. | |
And this script is dirty. | |
Change the path at line 17 for the correct '.\merge.txt' generated. | |
You can set a longer delay to cancel between jobs by putting a longer $waitfor at line 15. 5 seconds by default. | |
#> | |
$counter = 0 | |
$wait = 0 | |
$waitfor = 5 | |
$merge_commands = Get-Content .\merge_example.txt # ##### Change this for the correct file. | |
$merge_commands | % { | |
$counter++; | |
Write-Verbose $_ | |
$wait = 0 | |
$writeProgressSplat = @{ | |
Activity = $("Sleeping {0} seconds between merge" -f $waitfor) | |
PercentComplete = ( ($wait) / $waitfor * 100) | |
Status = $("{0} / {1} seconds" -f ($wait), $waitfor) | |
} | |
Write-Progress @writeProgressSplat | |
while ( | |
$wait -lt $waitfor | |
) { | |
Start-Sleep -Milliseconds 100 | |
$wait++; | |
$writeProgressSplat = @{ | |
Activity = $("Sleeping {0} seconds between merge" -f $waitfor) | |
PercentComplete = ( ($wait) / $waitfor * 100) | |
Status = $("{0} / {1} seconds" -f ($wait), $waitfor) | |
} | |
Write-Progress @writeProgressSplat | |
Start-Sleep -Seconds 1 | |
} | |
Write-Progress -Activity $writeProgressSplat.Activity -Completed | |
# Read-Host -Prompt "Waiting for user" | Out-Null | |
# Start-Sleep -Milliseconds 100 | |
Write-Progress -Activity "Merging All Disks" -PercentComplete $($counter / $merge_commands.Length * 100) -Status $_ | |
Invoke-Expression -Command $_ | |
} | |
Write-Progress -Activity "Merging All Disks" -Completed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment