Add log messages

This commit is contained in:
Manuel Thalmann 2023-06-22 17:18:50 +02:00
parent 879f34f22a
commit f39076dbff
3 changed files with 10 additions and 0 deletions

View file

@ -2,6 +2,7 @@
. "$PSScriptRoot/../../../scripts/Windows/Scripts/Context.ps1";
$null = New-Module {
Write-Information "Starting Restoration of Windows";
. "$PSScriptRoot/../../../scripts/Windows/OS/Install.ps1";
[Context]$context = [Context]::new();
$context.EntryPoint = "$($MyInvocation.MyCommand.Path)";

View file

@ -3,6 +3,7 @@
function Invoke-WindowsInstallation([Context] $context)
{
Write-Information "Starting Installation and Restoration of Windows";
. "$PSScriptRoot/../Scripts/Prerequisites.ps1";
Invoke-Upgrade $context;
Invoke-WindowsRestore $context;

View file

@ -1,20 +1,28 @@
function Invoke-Upgrade([Context] $context)
{
Write-Information "Upgrading Windows";
Write-Information "Preparing for Windows Update";
$null = Import-Module PSWindowsUpdate;
Write-Information "Performing Windows Update";
$null = Install-WindowsUpdate -AcceptAll -IgnoreReboot;
if ((Get-WURebootStatus).RebootRequired)
{
Write-Debug "A Reboot is Required!";
Write-Debug "Windows will reboot now and the installation will be continued automatically.";
$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)
{
Write-Debug "More updates are available. Restarting upgrade routine.";
$null = Invoke-Upgrade $context;
return;
}
else
{
Write-Host "Upgrading Windows finished successfully!";
return;
}
}