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:WIN_COMPUTER_NAME = "DerGeret";
|
||||||
$env:SETUP_SCRIPT_NAME = "$PSScriptRoot/Restore.ps1";
|
$env:SETUP_SCRIPT_NAME = "$PSScriptRoot/Restore.ps1";
|
||||||
|
|
||||||
$Global:SetupConfigPostprocessor = {
|
function Initialize-SetupConfig() {
|
||||||
param([xml] $config, [System.Xml.XmlNamespaceManager] $namespace)
|
param(
|
||||||
|
[xml] $config,
|
||||||
$setupComponent = $config.SelectSingleNode(
|
[System.Xml.XmlNamespaceManager] $namespace
|
||||||
"/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);
|
|
||||||
|
|
||||||
|
New-Module {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Increases the ID of all partitions in the specified range by 1.
|
Increases the ID of all partitions in the specified range by 1.
|
||||||
|
@ -107,7 +98,20 @@ $Global:SetupConfigPostprocessor = {
|
||||||
|
|
||||||
Move-PartitionRange -1 0 ($To + 1)
|
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)";
|
$partitionCreations[1].SelectSingleNode("./ua:Size", $namespace).InnerText = "$(1024)";
|
||||||
Invoke-PartitionRelocation 2 1;
|
Invoke-PartitionRelocation 2 1;
|
||||||
|
|
||||||
|
|
|
@ -39,12 +39,12 @@ $newCommand.SelectSingleNode("./ua:CommandLine", $namespace).InnerText = `
|
||||||
$(Get-Content "$PSScriptRoot/InitialBoot.ps1") + `
|
$(Get-Content "$PSScriptRoot/InitialBoot.ps1") + `
|
||||||
"; pwsh '$([System.IO.Path]::GetRelativePath("$PSScriptRoot/../../..", $env:SETUP_SCRIPT_NAME))';";
|
"; pwsh '$([System.IO.Path]::GetRelativePath("$PSScriptRoot/../../..", $env:SETUP_SCRIPT_NAME))';";
|
||||||
|
|
||||||
$order = [int]$newCommand.SelectSingleNode("./ua:Order", $namespace).InnerText;
|
$orderElement = $newCommand.SelectSingleNode("./ua:Order", $namespace);
|
||||||
$newCommand.SelectSingleNode("./ua:Order", $namespace).InnerText = $order + 1;
|
$orderElement.InnerText = ([int]($orderElement.InnerText) + 1);
|
||||||
$newCommand.SelectSingleNode("./ua:Description", $namespace).InnerText = "Install PowerShell Core and git and run setup script";
|
$newCommand.SelectSingleNode("./ua:Description", $namespace).InnerText = "Install PowerShell Core and git and run setup script";
|
||||||
|
|
||||||
if ($Global:SetupConfigPostprocessor) {
|
if (Get-Command Initialize-SetupConfig) {
|
||||||
$Global:SetupConfigPostprocessor.Invoke($unattendedConfig, $namespace);
|
Initialize-SetupConfig $unattendedConfig $namespace;
|
||||||
}
|
}
|
||||||
|
|
||||||
$unattendedConfig.PreserveWhitespace = $true;
|
$unattendedConfig.PreserveWhitespace = $true;
|
||||||
|
|
Loading…
Reference in a new issue