Rearrange installation scripts
This commit is contained in:
parent
128acc5d90
commit
52834fcd92
4 changed files with 27 additions and 27 deletions
|
@ -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;
|
||||||
|
}
|
||||||
|
|
|
@ -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";
|
|
||||||
}
|
|
20
scripts/Windows/OS/Upgrade.ps1
Normal file
20
scripts/Windows/OS/Upgrade.ps1
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
class Context {
|
class Context {
|
||||||
|
[string]$EntryPoint;
|
||||||
[string]$RootDir;
|
[string]$RootDir;
|
||||||
[string]$BackupName;
|
[string]$BackupName;
|
||||||
[string] BackupRoot() {
|
[string] BackupRoot() {
|
||||||
|
|
Loading…
Reference in a new issue