mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-04-01 17:12:09 +00:00
add installation logic
- added verbose checkbox - added longtitle - added install selected logic - added install all logic
This commit is contained in:
parent
e830ff03b1
commit
a9675fc91b
@ -4,10 +4,42 @@ function Invoke-WPFUpdateMGMT {
|
||||
[switch]$All
|
||||
)
|
||||
|
||||
if ($Selected) {
|
||||
write-host "Installing selected updates"
|
||||
} elseif ($All) {
|
||||
Write-Host "Installing all available updates"
|
||||
if ($All) {
|
||||
Write-Host "Installing all available updates ..."
|
||||
Invoke-WPFRunspace -ArgumentList $sync["WPFUpdateVerbose"].IsChecked -DebugPreference $DebugPreference -ScriptBlock {
|
||||
param ($WPFUpdateVerbose)
|
||||
if ($WPFUpdateVerbose) {
|
||||
Install-WindowsUpdate -Verbose -Confirm:$false -IgnoreReboot:$true -IgnoreRebootRequired:$true
|
||||
} else {
|
||||
Install-WindowsUpdate -Confirm:$false -IgnoreReboot:$true -IgnoreRebootRequired:$true
|
||||
}
|
||||
Write-Host "All Update Processes Completed"
|
||||
}
|
||||
} elseif (($Selected) -and ($sync["WPFUpdatesList"].SelectedItems.Count -gt 0)) {
|
||||
write-host "Installing selected updates..."
|
||||
$selectedUpdates = $sync["WPFUpdatesList"].SelectedItems | ForEach-Object {
|
||||
[PSCustomObject]@{
|
||||
ComputerName = $_.ComputerName
|
||||
Title = $_.LongTitle
|
||||
KB = $_.KB
|
||||
Size = $_.Size
|
||||
}
|
||||
}
|
||||
Invoke-WPFRunspace -ParameterList @(("selectedUpdates", $selectedUpdates), ("WPFUpdateVerbose", $sync["WPFUpdateVerbose"].IsChecked)) -DebugPreference $DebugPreference -ScriptBlock {
|
||||
param ($selectedUpdates, $WPFUpdateVerbose)
|
||||
foreach ($update in $selectedUpdates) {
|
||||
Write-Host "Installing update $($update.Title) on $($update.ComputerName)"
|
||||
if ($WPFUpdateVerbose) {
|
||||
Get-WindowsUpdate -ComputerName $update.ComputerName -Title $update.Title -Install -Confirm:$false -Verbose -IgnoreReboot:$true -IgnoreRebootRequired:$true
|
||||
} else {
|
||||
Get-WindowsUpdate -ComputerName $update.ComputerName -Title $update.Title -Install -Confirm:$false -IgnoreReboot:$true -IgnoreRebootRequired:$true
|
||||
}
|
||||
}
|
||||
Write-Host "Selected Update Processes Completed"
|
||||
}
|
||||
} else {
|
||||
Write-Host "No updates selected"
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ function Invoke-WPFUpdatesScan {
|
||||
$sync.form.Dispatcher.Invoke([action] {
|
||||
foreach ($update in $updates) {
|
||||
$item = New-Object PSObject -Property @{
|
||||
LongTitle = $update.Title
|
||||
ComputerName = $update.ComputerName
|
||||
KB = $update.KB
|
||||
Size = $update.Size
|
||||
|
@ -1387,6 +1387,10 @@
|
||||
IsReadOnly="True"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="LongTitle"
|
||||
Binding="{Binding LongTitle}"
|
||||
Width="Auto"
|
||||
Visibility="Collapsed"/>
|
||||
<DataGridTextColumn Header="ComputerName"
|
||||
Binding="{Binding ComputerName}"
|
||||
Width="Auto"
|
||||
@ -1435,6 +1439,14 @@
|
||||
Orientation="Horizontal"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="5">
|
||||
<StackPanel VerticalAlignment="Center">
|
||||
<CheckBox x:Name="WPFUpdateVerbose"
|
||||
Content="Verbose Output"
|
||||
Margin="5"
|
||||
Padding="10,5"
|
||||
ToolTip="Verbose output for update installation"
|
||||
IsChecked="True"/>
|
||||
</StackPanel>
|
||||
<Button Name="WPFUpdateSelectedInstall"
|
||||
Content="Install Selected"
|
||||
Margin="5"
|
||||
|
Loading…
Reference in New Issue
Block a user