Commit a2da1a7d authored by Stefan Scherer's avatar Stefan Scherer
Browse files

make MaxUpdatesPerCycle command line param work

parent 3c96f735
param($global:RestartRequired=0,
$global:MoreUpdates=0,
$global:MaxCycles=5,
$global:MaxUpdatesPerCycle=500)
$MaxUpdatesPerCycle=500)
function Check-ContinueRestartOrEnd() {
$RegistryKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
......@@ -30,7 +30,7 @@ function Check-ContinueRestartOrEnd() {
$prop = (Get-ItemProperty $RegistryKey).$RegistryEntry
if (-not $prop) {
Write-Host "Restart Registry Entry Does Not Exist - Creating It"
Set-ItemProperty -Path $RegistryKey -Name $RegistryEntry -Value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File $($script:ScriptPath) -MaxUpdatesPerCycle $($global:MaxUpdatesPerCycle)"
Set-ItemProperty -Path $RegistryKey -Name $RegistryEntry -Value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File $($script:ScriptPath) -MaxUpdatesPerCycle $($MaxUpdatesPerCycle)"
} else {
Write-Host "Restart Registry Entry Exists Already"
}
......@@ -47,11 +47,11 @@ function Check-ContinueRestartOrEnd() {
function Install-WindowsUpdates() {
$script:Cycles++
Write-Host "Evaluating Available Updates with limit of $($global:MaxUpdatesPerCycle):"
Write-Host "Evaluating Available Updates with limit of $($MaxUpdatesPerCycle):"
$UpdatesToDownload = New-Object -ComObject 'Microsoft.Update.UpdateColl'
$script:i = 0;
$CurrentUpdates = $SearchResult.Updates | Select-Object
while($script:i -lt $CurrentUpdates.Count -and $script:CycleUpdateCount -lt $global:MaxUpdatesPerCycle) {
while($script:i -lt $CurrentUpdates.Count -and $script:CycleUpdateCount -lt $MaxUpdatesPerCycle) {
$Update = $CurrentUpdates[$script:i]
if (($Update -ne $null) -and (!$Update.IsDownloaded)) {
[bool]$addThisUpdate = $false
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment