Refactor Windows setup scripts
This commit is contained in:
parent
182727eb8d
commit
c5a401f7eb
2 changed files with 101 additions and 97 deletions
|
@ -2,22 +2,13 @@
|
|||
$env:WIN_COMPUTER_NAME = "DerGeret";
|
||||
$env:SETUP_SCRIPT_NAME = "$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);
|
||||
|
||||
$partitionCreationContainer = $diskConfig.SelectSingleNode("./ua:CreatePartitions", $namespace);
|
||||
$partitionCreations = $partitionCreationContainer.SelectNodes("./ua:CreatePartition", $namespace);
|
||||
|
||||
$partitionModificationContainer = $diskConfig.SelectSingleNode("./ua:ModifyPartitions", $namespace);
|
||||
$partitionModifications = $partitionModificationContainer.SelectNodes("./ua:ModifyPartition", $namespace);
|
||||
function Initialize-SetupConfig() {
|
||||
param(
|
||||
[xml] $config,
|
||||
[System.Xml.XmlNamespaceManager] $namespace
|
||||
);
|
||||
|
||||
New-Module {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Increases the ID of all partitions in the specified range by 1.
|
||||
|
@ -107,7 +98,20 @@ $Global:SetupConfigPostprocessor = {
|
|||
|
||||
Move-PartitionRange -1 0 ($To + 1)
|
||||
}
|
||||
}
|
||||
|
||||
$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);
|
||||
|
||||
$partitionCreationContainer = $diskConfig.SelectSingleNode("./ua:CreatePartitions", $namespace);
|
||||
$partitionCreations = $partitionCreationContainer.SelectNodes("./ua:CreatePartition", $namespace);
|
||||
|
||||
$partitionModificationContainer = $diskConfig.SelectSingleNode("./ua:ModifyPartitions", $namespace);
|
||||
$partitionModifications = $partitionModificationContainer.SelectNodes("./ua:ModifyPartition", $namespace);
|
||||
$partitionCreations[1].SelectSingleNode("./ua:Size", $namespace).InnerText = "$(1024)";
|
||||
Invoke-PartitionRelocation 2 1;
|
||||
|
||||
|
|
|
@ -39,12 +39,12 @@ $newCommand.SelectSingleNode("./ua:CommandLine", $namespace).InnerText = `
|
|||
$(Get-Content "$PSScriptRoot/InitialBoot.ps1") + `
|
||||
"; pwsh '$([System.IO.Path]::GetRelativePath("$PSScriptRoot/../../..", $env:SETUP_SCRIPT_NAME))';";
|
||||
|
||||
$order = [int]$newCommand.SelectSingleNode("./ua:Order", $namespace).InnerText;
|
||||
$newCommand.SelectSingleNode("./ua:Order", $namespace).InnerText = $order + 1;
|
||||
$orderElement = $newCommand.SelectSingleNode("./ua:Order", $namespace);
|
||||
$orderElement.InnerText = ([int]($orderElement.InnerText) + 1);
|
||||
$newCommand.SelectSingleNode("./ua:Description", $namespace).InnerText = "Install PowerShell Core and git and run setup script";
|
||||
|
||||
if ($Global:SetupConfigPostprocessor) {
|
||||
$Global:SetupConfigPostprocessor.Invoke($unattendedConfig, $namespace);
|
||||
if (Get-Command Initialize-SetupConfig) {
|
||||
Initialize-SetupConfig $unattendedConfig $namespace;
|
||||
}
|
||||
|
||||
$unattendedConfig.PreserveWhitespace = $true;
|
||||
|
|
Loading…
Reference in a new issue