Compare commits

...

2 commits

2 changed files with 22 additions and 14 deletions

View file

@ -186,6 +186,20 @@ function Start-Setup {
Move-PartitionRange -Disk $Disk -1 -1 ($To + 1) Move-PartitionRange -Disk $Disk -1 -1 ($To + 1)
} }
function Add-StartupCommand {
param(
[string] $Script,
[string] $Description
)
$installationCommand = $oobeSettings.SelectSingleNode("./ua:FirstLogonCommands/ua:SynchronousCommand[last()]", $namespace);
$newCommand = $installationCommand.ParentNode.AppendChild($installationCommand.CloneNode($true));
$newCommand.SelectSingleNode("./ua:CommandLine", $namespace).InnerText = $Script;
$orderElement = $newCommand.SelectSingleNode("./ua:Order", $namespace);
$orderElement.InnerText = ([int]($orderElement.InnerText) + 1);
$newCommand.SelectSingleNode("./ua:Description", $namespace).InnerText = $Description;
}
# Collect necessary variables # Collect necessary variables
$winpePass = Get-PassSettings "windowsPE"; $winpePass = Get-PassSettings "windowsPE";
$setupConfig = Get-Component $winpePass "Microsoft-Windows-Setup"; $setupConfig = Get-Component $winpePass "Microsoft-Windows-Setup";
@ -213,19 +227,13 @@ function Start-Setup {
$oobeSettings.SelectSingleNode($xpath, $namespace).InnerText = $valhallaConfig.setupUser; $oobeSettings.SelectSingleNode($xpath, $namespace).InnerText = $valhallaConfig.setupUser;
} }
$installationCommand = $oobeSettings.SelectSingleNode("./ua:FirstLogonCommands/ua:SynchronousCommand[last()]", $namespace); Add-StartupCommand -Script `
$newCommand = $installationCommand.ParentNode.AppendChild($installationCommand.CloneNode($true));
$newCommand.SelectSingleNode("./ua:CommandLine", $namespace).InnerText = `
"powershell -Command " + ` "powershell -Command " + `
"`$env:PWSH_PATH = $(Get-PathInjection $env:PWSH_PATH);" + ` "`$env:PWSH_PATH = $(Get-PathInjection $env:PWSH_PATH);" + `
"`$env:INSTALLER_SCRIPT = $(Get-ScriptPathInjection $env:SETUP_SCRIPT_NAME);" + ` "`$env:INSTALLER_SCRIPT = $(Get-ScriptPathInjection $env:SETUP_SCRIPT_NAME);" + `
"`$env:CONFIG_MODULE = $(Get-ScriptPathInjection $env:CONFIG_MODULE);" + ` "`$env:CONFIG_MODULE = $(Get-ScriptPathInjection $env:CONFIG_MODULE);" + `
"& (Join-Path `$env:PWSH_PATH pwsh) `$env:INSTALLER_SCRIPT;"; "& (Join-Path `$env:PWSH_PATH pwsh) `$env:INSTALLER_SCRIPT;" `
-Description "Install PowerShell Core and git and run setup script";
$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 ($valhallaConfig.dualboot.enable) { if ($valhallaConfig.dualboot.enable) {
$diskSize = [long](ConvertFrom-Csv (wmic diskdrive where "Index=$(Get-InstallDisk)" get Size | ForEach-Object { "$_".Trim(); })).Size; $diskSize = [long](ConvertFrom-Csv (wmic diskdrive where "Index=$(Get-InstallDisk)" get Size | ForEach-Object { "$_".Trim(); })).Size;

View file

@ -104,7 +104,7 @@ $null = New-Module {
$writer = [XmlWriter]::Create($configFile.FullName, $writerSettings); $writer = [XmlWriter]::Create($configFile.FullName, $writerSettings);
$document.Save($writer); $document.Save($writer);
$writer.Dispose(); $writer.Dispose();
DISM /Online "/Import-DefaultAppAssociations:$($configFile.FullName)"; $null = DISM /Online "/Import-DefaultAppAssociations:$($configFile.FullName)";
Remove-Item $configFile; Remove-Item $configFile;
} }
} }