@@ -4,10 +4,42 @@ function Invoke-WPFUpdateMGMT {
44 [switch ]$All
55 )
66
7- if ($Selected ) {
8- write-host " Installing selected updates"
9- } elseif ($All ) {
10- Write-Host " Installing all available updates"
7+ if ($All ) {
8+ Write-Host " Installing all available updates ..."
9+ Invoke-WPFRunspace - ArgumentList $sync [" WPFUpdateVerbose" ].IsChecked - DebugPreference $DebugPreference - ScriptBlock {
10+ param ($WPFUpdateVerbose )
11+ if ($WPFUpdateVerbose ) {
12+ Install-WindowsUpdate - Verbose - Confirm:$false - IgnoreReboot:$true - IgnoreRebootRequired:$true
13+ } else {
14+ Install-WindowsUpdate - Confirm:$false - IgnoreReboot:$true - IgnoreRebootRequired:$true
15+ }
16+ Write-Host " All Update Processes Completed"
17+ }
18+ } elseif (($Selected ) -and ($sync [" WPFUpdatesList" ].SelectedItems.Count -gt 0 )) {
19+ write-host " Installing selected updates..."
20+ $selectedUpdates = $sync [" WPFUpdatesList" ].SelectedItems | ForEach-Object {
21+ [PSCustomObject ]@ {
22+ ComputerName = $_.ComputerName
23+ Title = $_.LongTitle
24+ KB = $_.KB
25+ Size = $_.Size
26+ }
27+ }
28+ Invoke-WPFRunspace - ParameterList @ ((" selectedUpdates" , $selectedUpdates ), (" WPFUpdateVerbose" , $sync [" WPFUpdateVerbose" ].IsChecked)) - DebugPreference $DebugPreference - ScriptBlock {
29+ param ($selectedUpdates , $WPFUpdateVerbose )
30+ foreach ($update in $selectedUpdates ) {
31+ Write-Host " Installing update $ ( $update.Title ) on $ ( $update.ComputerName ) "
32+ if ($WPFUpdateVerbose ) {
33+ Get-WindowsUpdate - ComputerName $update.ComputerName - Title $update.Title - Install - Confirm:$false - Verbose - IgnoreReboot:$true - IgnoreRebootRequired:$true
34+ } else {
35+ Get-WindowsUpdate - ComputerName $update.ComputerName - Title $update.Title - Install - Confirm:$false - IgnoreReboot:$true - IgnoreRebootRequired:$true
36+ }
37+ }
38+ Write-Host " Selected Update Processes Completed"
39+ }
40+ } else {
41+ Write-Host " No updates selected"
42+ return
1143 }
1244
1345}
0 commit comments