Suppress unnecessary errors
This commit is contained in:
parent
e2de8ec4b4
commit
e8a6492566
2 changed files with 6 additions and 6 deletions
|
@ -7,16 +7,16 @@ function Update-WindowsInstallation([Context] $context)
|
||||||
$null = Import-Module PSWindowsUpdate;
|
$null = Import-Module PSWindowsUpdate;
|
||||||
|
|
||||||
Write-Host "Performing Windows Update";
|
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 "A Reboot is Required!";
|
||||||
Write-Information "Windows will reboot now and the installation will be continued automatically.";
|
Write-Information "Windows will reboot now and the installation will be continued automatically.";
|
||||||
$context.Reboot();
|
$context.Reboot();
|
||||||
exit;
|
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.";
|
Write-Information "More updates are available. Restarting upgrade routine.";
|
||||||
$null = Update-WindowsInstallation $context;
|
$null = Update-WindowsInstallation $context;
|
||||||
|
|
|
@ -209,9 +209,9 @@ class Context {
|
||||||
param ($logon)
|
param ($logon)
|
||||||
$path = $logon.PSPath;
|
$path = $logon.PSPath;
|
||||||
Set-ItemProperty $path -Name "AutoAdminLogon" 0;
|
Set-ItemProperty $path -Name "AutoAdminLogon" 0;
|
||||||
Remove-ItemProperty $path -Name "DefaultDomainName";
|
Remove-ItemProperty $path -Name "DefaultDomainName" -ErrorAction SilentlyContinue;
|
||||||
Remove-ItemProperty $path -Name "DefaultUserName";
|
Remove-ItemProperty $path -Name "DefaultUserName" -ErrorAction SilentlyContinue;
|
||||||
Remove-ItemProperty $path -Name "DefaultPassword";
|
Remove-ItemProperty $path -Name "DefaultPassword" -ErrorAction SilentlyContinue;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue