Suppress unnecessary errors

This commit is contained in:
Manuel Thalmann 2023-07-03 01:14:34 +02:00
parent 1e6aec1e30
commit d52de2f40a
2 changed files with 6 additions and 6 deletions

View file

@ -7,16 +7,16 @@ function Update-WindowsInstallation([Context] $context)
$null = Import-Module PSWindowsUpdate;
Write-Host "Performing Windows Update";
$null = Install-WindowsUpdate -AcceptAll -IgnoreReboot;
$null = Install-WindowsUpdate -AcceptAll -IgnoreReboot -ErrorAction SilentlyContinue;
if ((Get-WURebootStatus -Silent))
if ((Get-WURebootStatus -Silent -ErrorAction SilentlyContinue))
{
Write-Information "A Reboot is Required!";
Write-Information "Windows will reboot now and the installation will be continued automatically.";
$context.Reboot();
exit;
}
elseif ((Get-WindowsUpdate -IgnoreReboot).Count -gt 0)
elseif ((Get-WindowsUpdate -IgnoreReboot -ErrorAction SilentlyContinue).Count -gt 0)
{
Write-Information "More updates are available. Restarting upgrade routine.";
$null = Update-WindowsInstallation $context;

View file

@ -209,9 +209,9 @@ class Context {
param ($logon)
$path = $logon.PSPath;
Set-ItemProperty $path -Name "AutoAdminLogon" 0;
Remove-ItemProperty $path -Name "DefaultDomainName";
Remove-ItemProperty $path -Name "DefaultUserName";
Remove-ItemProperty $path -Name "DefaultPassword";
Remove-ItemProperty $path -Name "DefaultDomainName" -ErrorAction SilentlyContinue;
Remove-ItemProperty $path -Name "DefaultUserName" -ErrorAction SilentlyContinue;
Remove-ItemProperty $path -Name "DefaultPassword" -ErrorAction SilentlyContinue;
});
}