Skip to content

Commit a9675fc

Browse files
committed
add installation logic
- added verbose checkbox - added longtitle - added install selected logic - added install all logic
1 parent e830ff0 commit a9675fc

File tree

3 files changed

+49
-4
lines changed

3 files changed

+49
-4
lines changed

functions/public/Invoke-WPFUpdateMGMGT.ps1

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

functions/public/Invoke-WPFUpdatesScan.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ function Invoke-WPFUpdatesScan {
3434
$sync.form.Dispatcher.Invoke([action] {
3535
foreach ($update in $updates) {
3636
$item = New-Object PSObject -Property @{
37+
LongTitle = $update.Title
3738
ComputerName = $update.ComputerName
3839
KB = $update.KB
3940
Size = $update.Size

xaml/inputXML.xaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,6 +1387,10 @@
13871387
IsReadOnly="True"
13881388
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
13891389
<DataGrid.Columns>
1390+
<DataGridTextColumn Header="LongTitle"
1391+
Binding="{Binding LongTitle}"
1392+
Width="Auto"
1393+
Visibility="Collapsed"/>
13901394
<DataGridTextColumn Header="ComputerName"
13911395
Binding="{Binding ComputerName}"
13921396
Width="Auto"
@@ -1435,6 +1439,14 @@
14351439
Orientation="Horizontal"
14361440
HorizontalAlignment="Right"
14371441
Margin="5">
1442+
<StackPanel VerticalAlignment="Center">
1443+
<CheckBox x:Name="WPFUpdateVerbose"
1444+
Content="Verbose Output"
1445+
Margin="5"
1446+
Padding="10,5"
1447+
ToolTip="Verbose output for update installation"
1448+
IsChecked="True"/>
1449+
</StackPanel>
14381450
<Button Name="WPFUpdateSelectedInstall"
14391451
Content="Install Selected"
14401452
Margin="5"

0 commit comments

Comments
 (0)