Rearrange installation scripts

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

View file

@ -1,4 +1,8 @@
. "$PSScriptRoot/Manage.ps1"; . "$PSScriptRoot/Manage.ps1";
$context = [Context]::new(); function Invoke-WindowsInstallation([Context] $context)
Invoke-WindowsRestore $context; {
. "$PSScriptRoot/../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 { class Context {
[string]$EntryPoint;
[string]$RootDir; [string]$RootDir;
[string]$BackupName; [string]$BackupName;
[string] BackupRoot() { [string] BackupRoot() {