From cda0a62bf09a30d3e774d67f30b56a0f8f621663 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Sat, 23 Mar 2024 14:00:42 +0100 Subject: [PATCH] Improve partition script --- profiles/DerGeret/Windows/Setup.ps1 | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/profiles/DerGeret/Windows/Setup.ps1 b/profiles/DerGeret/Windows/Setup.ps1 index e0f64f4c..603fa45f 100644 --- a/profiles/DerGeret/Windows/Setup.ps1 +++ b/profiles/DerGeret/Windows/Setup.ps1 @@ -9,6 +9,14 @@ function Initialize-SetupConfig() { ); New-Module { + <# + .SYNOPSIS + Gets the XML element describing the installation partition ID. + #> + Get-InstallationPartition { + $setupComponent.SelectSingleNode("./ua:ImageInstall/ua:OSImage/ua:InstallTo/ua:PartitionID", $namespace) + } + <# .SYNOPSIS Increases the ID of all partitions in the specified range by 1. @@ -20,12 +28,15 @@ function Initialize-SetupConfig() { [int]$By = 1 ) + # Update installation partition ID if necessary + $installationPartition = Get-InstallationPartition; $installPartitionID = [int]$installationPartition.InnerText; if (($installPartitionID -ge $From) -and (($null -eq $To) -or ($installPartitionID -lt $To))) { $installationPartition.InnerText = "$($installPartitionID + $By)"; } + # Update IDs of all partition creations foreach ($partition in $partitionCreations) { $orderNode = $partition.SelectSingleNode("./ua:Order", $namespace); $order = [int]$orderNode.InnerText; @@ -40,6 +51,7 @@ function Initialize-SetupConfig() { } } + # Update IDs of all partition modifications foreach ($partition in $partitionModifications) { $partitionNode = $partition.SelectSingleNode("./ua:PartitionID", $namespace); $partitionID = [int]$partitionNode.InnerText; @@ -105,7 +117,6 @@ function Initialize-SetupConfig() { $namespace); $diskConfig = $setupComponent.SelectSingleNode("./ua:DiskConfiguration/ua:Disk", $namespace); - $installationPartition = $setupComponent.SelectSingleNode("./ua:ImageInstall/ua:OSImage/ua:InstallTo/ua:PartitionID", $namespace); $partitionCreationContainer = $diskConfig.SelectSingleNode("./ua:CreatePartitions", $namespace); $partitionCreations = $partitionCreationContainer.SelectNodes("./ua:CreatePartition", $namespace);