Make Move-PartitionRange zero-based

This commit is contained in:
Manuel Thalmann 2024-03-23 14:06:30 +01:00
parent de9fd86b6e
commit 221319d986

View file

@ -32,7 +32,7 @@ function Initialize-SetupConfig() {
$installationPartition = Get-InstallationPartition; $installationPartition = Get-InstallationPartition;
$installPartitionID = [int]$installationPartition.InnerText; $installPartitionID = [int]$installationPartition.InnerText;
if (($installPartitionID -ge $From) -and (($null -eq $To) -or ($installPartitionID -lt $To))) { if (($installPartitionID -ge $From) -and (($null -eq $To) -or ($installPartitionID -le $To))) {
$installationPartition.InnerText = "$($installPartitionID + $By)"; $installationPartition.InnerText = "$($installPartitionID + $By)";
} }
@ -42,7 +42,7 @@ function Initialize-SetupConfig() {
$order = [int]$orderNode.InnerText; $order = [int]$orderNode.InnerText;
$newOrder = $order; $newOrder = $order;
if (($newOrder -ge $From) -and (($null -eq $To) -or ($newOrder -lt $To))) { if (($newOrder -ge $From) -and (($null -eq $To) -or ($newOrder -le $To))) {
$newOrder += $By; $newOrder += $By;
} }
@ -57,7 +57,7 @@ function Initialize-SetupConfig() {
$partitionID = [int]$partitionNode.InnerText; $partitionID = [int]$partitionNode.InnerText;
$newID = $partitionID; $newID = $partitionID;
if (($newID -ge $From) -and (($null -eq $To) -or ($newID -lt $To))) { if (($newID -ge $From) -and (($null -eq $To) -or ($newID -le $To))) {
$newID += $By; $newID += $By;
} }
@ -99,16 +99,16 @@ function Initialize-SetupConfig() {
[int]$To [int]$To
) )
Move-PartitionRange $From ($From + 1) (-1 * ($From + 1)) Move-PartitionRange $From $From (-1 * ($From + 1))
if ($From -gt $To) { if ($From -gt $To) {
Move-PartitionRange $To $From; Move-PartitionRange $To ($From - 1);
} }
elseif ($From -lt $To) { elseif ($From -lt $To) {
Move-PartitionRange $From ($To + 1) -1; Move-PartitionRange ($From + 1) $To -1;
} }
Move-PartitionRange -1 0 ($To + 1) Move-PartitionRange -1 -1 ($To + 1)
} }
} }