$env:WIN_COMPUTER_NAME = "DerGeret"; $env:SETUP_SCRIPT_NAME = [System.IO.Path]::GetRelativePath("$PSScriptRoot/../../..", "$PSScriptRoot/Restore.ps1"); $Global:SetupConfigPostprocessor = { param([xml] $config, [System.Xml.XmlNamespaceManager] $namespace) $setupComponent = $config.SelectSingleNode( "/ua:unattend/ua:settings[@pass='windowsPE']/ua:component[@name='Microsoft-Windows-Setup']", $namespace); $diskConfig = $setupComponent.SelectSingleNode("./ua:DiskConfiguration/ua:Disk", $namespace); $installationPartition = $setupComponent.SelectSingleNode("./ua:ImageInstall/ua:OSImage/ua:InstallTo/ua:PartitionID", $namespace); $newIndex = 2; $installationPartition.InnerText = "$($newIndex + 3)"; $partitionCreationContainer = $diskConfig.SelectSingleNode("./ua:CreatePartitions", $namespace); $partitionCreations = $partitionCreationContainer.SelectNodes("./ua:CreatePartition", $namespace); $garbage = 0; foreach ($partition in $partitionCreations) { $order = [int]$partition.SelectSingleNode("./ua:Order", $namespace).InnerText; $newOrder = $order; if ($order -eq 2) { $newOrder--; } else { $garbage += [int]$partition.SelectSingleNode("./ua:Size", $namespace).InnerText; if ($newOrder -lt 2) { $newOrder++; } if ($newOrder -ge $newIndex) { $newOrder++; } } if ($order -ne $newOrder) { $partition.SelectSingleNode("./ua:Order", $namespace).InnerText = "$newOrder"; } } # Add space before Windows installation... wha-!? For Linux, ofc! I use Arch Linux, btw. $newPartition = $partitionCreations[0].CloneNode($true); $newPartition.SelectSingleNode("./ua:Order", $namespace).InnerText = "$newIndex"; $newPartition.SelectSingleNode("./ua:Size", $namespace).InnerText = "$(64 * 1024)"; $null = $partitionCreationContainer.AppendChild($newPartition); $partitionModificationContainer = $diskConfig.SelectSingleNode("./ua:ModifyPartitions", $namespace); $partitionModifications = $partitionModificationContainer.SelectNodes("./ua:ModifyPartition", $namespace); $newModification = $partitionModifications[2].CloneNode($true); $newModification.SelectSingleNode("./ua:Order", $namespace).InnerText = "$newIndex"; $newModification.SelectSingleNode("./ua:PartitionID", $namespace).InnerText = "$newIndex"; foreach ($partition in $partitionModifications) { $partitionID = [int]$partition.SelectSingleNode("./ua:PartitionID", $namespace).InnerText; $newID = $partitionID; if ($partitionID -eq 2) { $newID--; } else { if ($newID -lt 2) { $newID++; } if ($newID -ge $newIndex) { $newID++; } } if ($partitionID -ne $newID) { $partition.SelectSingleNode("./ua:PartitionID", $namespace).InnerText = "$newID"; $partition.SelectSingleNode("./ua:Order", $namespace).InnerText = "$newID"; } } $null = $partitionModificationContainer.AppendChild($newModification); } . "$PSScriptRoot/../../../scripts/Windows/OS/Setup.ps1";