Rearrange installation scripts

This commit is contained in:
Manuel Thalmann 2023-06-21 22:04:18 +02:00
parent f49d0554f0
commit abb8a78f68
4 changed files with 27 additions and 27 deletions

View file

@ -1,4 +1,8 @@
. "$PSScriptRoot/Manage.ps1";
$context = [Context]::new();
Invoke-WindowsRestore $context;
function Invoke-WindowsInstallation([Context] $context)
{
. "$PSScriptRoot/../../../scripts/Windows/Scripts/Prerequisites.ps1";
Invoke-Upgrade $context;
Invoke-WindowsRestore $context;
}

View file

@ -1,25 +0,0 @@
Import-Module PSWindowsUpdate;
Import-Module ScheduledTasks;
$installerPath = "$PSScriptRoot/Install.ps1";
$setupPath = "$($MyInvocation.MyCommand.Path)";
Install-WindowsUpdate -AcceptAll -IgnoreReboot;
if ((Get-WindowsUpdate).Count -gt 0)
{
$nextScript = "$setupPath";
}
else
{
$nextScript = "$installerPath";
}
if ((Get-WURebootStatus).RebootRequired)
{
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\RunOnce" -Name "PortValhalla" -Value "pwsh `"$nextScript`"" -PropertyType ExpandString;
}
else
{
. "$nextScript";
}

View file

@ -0,0 +1,20 @@
function Invoke-Upgrade([Context] $context)
{
$null = Import-Module PSWindowsUpdate;
$null = Install-WindowsUpdate -AcceptAll -IgnoreReboot;
if ((Get-WURebootStatus).RebootRequired)
{
$null = New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\RunOnce" -Name "PortValhalla" -Value "pwsh `"$($context.EntryPoint)`"" -PropertyType ExpandString;
exit;
}
elseif ((Get-WindowsUpdate).Count -gt 0)
{
$null = Invoke-Upgrade $context;
return;
}
else
{
return;
}
}

View file

@ -1,4 +1,5 @@
class Context {
[string]$EntryPoint;
[string]$RootDir;
[string]$BackupName;
[string] BackupRoot() {