Add scripts for updating windows
This commit is contained in:
parent
ee077e0765
commit
12c449eb7c
2 changed files with 58 additions and 11 deletions
scripts/Windows/Scripts
34
scripts/Windows/Scripts/Update.ps1
Normal file
34
scripts/Windows/Scripts/Update.ps1
Normal file
|
@ -0,0 +1,34 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Updates the running Windows machine.
|
||||
#>
|
||||
function Update-WindowsInstallation {
|
||||
<#
|
||||
Runs the Windows update loop.
|
||||
#>
|
||||
function Start-UpdateLoop {
|
||||
Write-Host "Preparing for Windows Update";
|
||||
$null = Import-Module PSWindowsUpdate;
|
||||
|
||||
while (((Get-WindowsUpdate -IgnoreReboot).Count -gt 0)) {
|
||||
Write-Host "There are updates available.";
|
||||
Write-Host "Installing updates";
|
||||
|
||||
try {
|
||||
$null = Install-WindowsUpdate -AcceptAll -IgnoreReboot -ErrorAction "SilentlyContinue";
|
||||
}
|
||||
catch { }
|
||||
|
||||
if ((Get-WURebootStatus -Silent)) {
|
||||
Write-Information "A Reboot is Required!";
|
||||
Write-Information "Windows will reboot now and the installation will be continued automatically.";
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
Write-Information "Upgrading Windows finished successfully!";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Start-UpdateLoop;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue