Add Taskbaritem indication

This commit is contained in:
MyDrift 2025-03-07 15:23:29 +01:00
parent a9675fc91b
commit 8fabebedf4
3 changed files with 12 additions and 1 deletions

View File

@ -4,6 +4,8 @@ function Invoke-WPFUpdateMGMT {
[switch]$All [switch]$All
) )
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Indeterminate" -value 0.01 -overlay "logo" })
if ($All) { if ($All) {
Write-Host "Installing all available updates ..." Write-Host "Installing all available updates ..."
Invoke-WPFRunspace -ArgumentList $sync["WPFUpdateVerbose"].IsChecked -DebugPreference $DebugPreference -ScriptBlock { Invoke-WPFRunspace -ArgumentList $sync["WPFUpdateVerbose"].IsChecked -DebugPreference $DebugPreference -ScriptBlock {
@ -13,7 +15,9 @@ function Invoke-WPFUpdateMGMT {
} else { } else {
Install-WindowsUpdate -Confirm:$false -IgnoreReboot:$true -IgnoreRebootRequired:$true Install-WindowsUpdate -Confirm:$false -IgnoreReboot:$true -IgnoreRebootRequired:$true
} }
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "None" -overlay "checkmark" })
Write-Host "All Update Processes Completed" Write-Host "All Update Processes Completed"
#catch $sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Error" -overlay "warning" })
} }
} elseif (($Selected) -and ($sync["WPFUpdatesList"].SelectedItems.Count -gt 0)) { } elseif (($Selected) -and ($sync["WPFUpdatesList"].SelectedItems.Count -gt 0)) {
write-host "Installing selected updates..." write-host "Installing selected updates..."
@ -35,11 +39,12 @@ function Invoke-WPFUpdateMGMT {
Get-WindowsUpdate -ComputerName $update.ComputerName -Title $update.Title -Install -Confirm:$false -IgnoreReboot:$true -IgnoreRebootRequired:$true Get-WindowsUpdate -ComputerName $update.ComputerName -Title $update.Title -Install -Confirm:$false -IgnoreReboot:$true -IgnoreRebootRequired:$true
} }
} }
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "None" -overlay "checkmark" })
Write-Host "Selected Update Processes Completed" Write-Host "Selected Update Processes Completed"
#catch $sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Error" -overlay "warning" })
} }
} else { } else {
Write-Host "No updates selected" Write-Host "No updates selected"
return return
} }
} }

View File

@ -1,4 +1,5 @@
function Invoke-WPFUpdateScanHistory { function Invoke-WPFUpdateScanHistory {
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Indeterminate" -value 0.01 -overlay "logo" })
$sync["WPFUpdateHistory"].Items.Clear() $sync["WPFUpdateHistory"].Items.Clear()
Invoke-WPFRunspace -DebugPreference $DebugPreference -ScriptBlock { Invoke-WPFRunspace -DebugPreference $DebugPreference -ScriptBlock {
write-host "Scanning for Windows update history..." write-host "Scanning for Windows update history..."
@ -35,6 +36,8 @@ function Invoke-WPFUpdateScanHistory {
$sync["WPFUpdateHistory"].Columns[0].Visibility = "Collapsed" $sync["WPFUpdateHistory"].Columns[0].Visibility = "Collapsed"
} }
}) })
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "None" -overlay "checkmark" })
#catch $sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Error" -overlay "warning" })
} }
else { else {
$sync.form.Dispatcher.Invoke([action] { $sync.form.Dispatcher.Invoke([action] {

View File

@ -2,6 +2,7 @@ function Invoke-WPFUpdatesScan {
Invoke-WPFRunspace -DebugPreference $DebugPreference -ScriptBlock { Invoke-WPFRunspace -DebugPreference $DebugPreference -ScriptBlock {
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Indeterminate" -value 0.01 -overlay "logo" })
# Check if the PSWindowsUpdate module is installed # Check if the PSWindowsUpdate module is installed
if (-not (Get-Module -ListAvailable -Name PSWindowsUpdate)) { if (-not (Get-Module -ListAvailable -Name PSWindowsUpdate)) {
try { try {
@ -51,8 +52,10 @@ function Invoke-WPFUpdatesScan {
$sync["WPFUpdatesList"].Columns[0].Visibility = "Collapsed" $sync["WPFUpdatesList"].Columns[0].Visibility = "Collapsed"
} }
}) })
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "None" -overlay "checkmark" })
} catch { } catch {
Write-Error "Error scanning for updates: $_" Write-Error "Error scanning for updates: $_"
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Error" -overlay "warning" })
} }
} }
} }