Add log messages

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

View file

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

View file

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

View file

@ -1,20 +1,28 @@
function Invoke-Upgrade([Context] $context) function Invoke-Upgrade([Context] $context)
{ {
Write-Information "Upgrading Windows";
Write-Information "Preparing for Windows Update";
$null = Import-Module PSWindowsUpdate; $null = Import-Module PSWindowsUpdate;
Write-Information "Performing Windows Update";
$null = Install-WindowsUpdate -AcceptAll -IgnoreReboot; $null = Install-WindowsUpdate -AcceptAll -IgnoreReboot;
if ((Get-WURebootStatus).RebootRequired) 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; $null = New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\RunOnce" -Name "PortValhalla" -Value "pwsh `"$($context.EntryPoint)`"" -PropertyType ExpandString;
exit; exit;
} }
elseif ((Get-WindowsUpdate).Count -gt 0) elseif ((Get-WindowsUpdate).Count -gt 0)
{ {
Write-Debug "More updates are available. Restarting upgrade routine.";
$null = Invoke-Upgrade $context; $null = Invoke-Upgrade $context;
return; return;
} }
else else
{ {
Write-Host "Upgrading Windows finished successfully!";
return; return;
} }
} }