2023-06-21 20:11:38 +00:00
|
|
|
$env:WIN_COMPUTER_NAME = "DerGeret";
|
|
|
|
$env:SETUP_SCRIPT_NAME = [System.IO.Path]::GetRelativePath("$PSScriptRoot/../../..", "$PSScriptRoot/Restore.ps1");
|
|
|
|
. "$PSScriptRoot/../../../scripts/Windows/OS/Setup.ps1";
|
2023-07-03 10:37:02 +00:00
|
|
|
|
|
|
|
$Global:SetupConfigPostprocessor = {
|
|
|
|
param([xml] $config, [System.Xml.XmlNamespaceManager] $namespace)
|
|
|
|
|
2023-07-03 10:40:28 +00:00
|
|
|
$setupComponent = $config.SelectSingleNode(
|
|
|
|
"/ua:unattend/ua:settings[@pass='windowsPE']/ua:component[@name='Microsoft-Windows-Setup']",
|
2023-07-03 10:37:02 +00:00
|
|
|
$namespace);
|
|
|
|
|
2023-07-03 10:40:28 +00:00
|
|
|
$diskConfig = $setupComponent.SelectSingleNode("./ua:DiskConfiguration/ua:Disk", $namespace);
|
|
|
|
$installationPartition = $setupComponent.SelectSingleNode("./ua:ImageInstall/ua:OSImage/ua:InstallTo/ua:PartitionID");
|
|
|
|
|
|
|
|
$newIndex = [int]$installationPartition.InnerText;
|
|
|
|
$installationPartition.InnerText = "$($newIndex + 1)";
|
2023-07-03 10:37:02 +00:00
|
|
|
$partitionCreations = $diskConfig.SelectSingleNode("./ua:CreatePartitions");
|
|
|
|
$newPartition = $partitionCreations.FirstChild.CloneNode($true);
|
|
|
|
$newPartition.SelectSingleNode("./ua:Order").InnerText = "$newIndex";
|
|
|
|
$newPartition.SelectSingleNode("./ua:Size").InnerText = "65536"; # For testing purposes
|
|
|
|
|
|
|
|
for ($i = 0; $i -lt $partitionCreations.ChildNodes.Count; $i++) {
|
|
|
|
$partition = $partitionCreations.ChildNodes[$i];
|
|
|
|
$order = [int]$partition.SelectSingleNode("./ua:Order").InnerText;
|
|
|
|
|
|
|
|
if ($order -ge $newIndex) {
|
|
|
|
$partition.SelectSingleNode("./ua:Order").InnerText = "$($order + 1)";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-03 10:45:26 +00:00
|
|
|
$partitionCreations.AppendChild($newPartition);
|
|
|
|
|
2023-07-03 10:37:02 +00:00
|
|
|
$partitionModifications = $diskConfig.SelectSingleNode("./ua:ModifyPartitions");
|
|
|
|
$newModification = $diskConfig.ChildNodes[2].CloneNode($true);
|
|
|
|
$newModification.SelectSingleNode("./ua:Order").InnerText = "$newIndex";
|
|
|
|
$newModification.SelectSingleNode("./ua:PartitionID").InnerText = "$newIndex";
|
|
|
|
|
|
|
|
for ($i = 0; $i -lt $partitionModifications.ChildNodes.Count; $i++) {
|
|
|
|
$partition = $partitionModifications.ChildNodes[$i];
|
|
|
|
$partitionID = [int]$partition.SelectSingleNode("./ua:PartitionID").InnerText;
|
|
|
|
|
|
|
|
if ($partitionID -ge $newIndex) {
|
|
|
|
$partition.SelectSingleNode("./ua:PartitionID").InnerText = "$($partitionID + 1)";
|
|
|
|
$partition.SelectSingleNode("./ua:Order").InnerText = "$($partitionID + 1)";
|
|
|
|
}
|
|
|
|
}
|
2023-07-03 10:45:26 +00:00
|
|
|
|
|
|
|
$partitionModifications.AppendChild($newModification);
|
2023-07-03 10:37:02 +00:00
|
|
|
}
|