mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-07-01 02:22:34 -05:00
Compare commits
3 Commits
8fabebedf4
...
27a97e4650
Author | SHA1 | Date | |
---|---|---|---|
27a97e4650 | |||
dc236b9865 | |||
f9878a3472 |
@ -4,6 +4,11 @@ function Invoke-WPFUpdateMGMT {
|
|||||||
[switch]$All
|
[switch]$All
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if ((-not $Selected -and -not $All) -or ($Selected -and $All)) {
|
||||||
|
Write-Host "[Invoke-WPFUpdateMGMT] Use either 'Selected' or 'All' switches, used switches are: 'Selected' is $Selected, 'All' is $All" -ForegroundColor Red
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Indeterminate" -value 0.01 -overlay "logo" })
|
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Indeterminate" -value 0.01 -overlay "logo" })
|
||||||
|
|
||||||
if ($All) {
|
if ($All) {
|
||||||
@ -33,10 +38,18 @@ function Invoke-WPFUpdateMGMT {
|
|||||||
param ($selectedUpdates, $WPFUpdateVerbose)
|
param ($selectedUpdates, $WPFUpdateVerbose)
|
||||||
foreach ($update in $selectedUpdates) {
|
foreach ($update in $selectedUpdates) {
|
||||||
Write-Host "Installing update $($update.Title) on $($update.ComputerName)"
|
Write-Host "Installing update $($update.Title) on $($update.ComputerName)"
|
||||||
|
if ($update.KB -ne "") {
|
||||||
if ($WPFUpdateVerbose) {
|
if ($WPFUpdateVerbose) {
|
||||||
Get-WindowsUpdate -ComputerName $update.ComputerName -Title $update.Title -Install -Confirm:$false -Verbose -IgnoreReboot:$true -IgnoreRebootRequired:$true
|
Get-WindowsUpdate -ComputerName $update.ComputerName -KBArticleID $update.KB -Install -Confirm:$false -Verbose -IgnoreReboot:$true -IgnoreRebootRequired:$true
|
||||||
} else {
|
} else {
|
||||||
Get-WindowsUpdate -ComputerName $update.ComputerName -Title $update.Title -Install -Confirm:$false -IgnoreReboot:$true -IgnoreRebootRequired:$true
|
Get-WindowsUpdate -ComputerName $update.ComputerName -KBArticleID $update.KB -Install -Confirm:$false -IgnoreReboot:$true -IgnoreRebootRequired:$true
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "None" -overlay "checkmark" })
|
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "None" -overlay "checkmark" })
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
function Invoke-WPFUpdatesScan {
|
function Invoke-WPFUpdatesScan {
|
||||||
|
$sync["WPFScanUpdates"].IsEnabled = $false
|
||||||
|
$sync["WPFUpdateSelectedInstall"].IsEnabled = $false
|
||||||
|
$sync["WPFUpdateAllInstall"].IsEnabled = $false
|
||||||
|
Set-WinUtilTaskbaritem -state "Indeterminate" -value 0.01 -overlay "logo"
|
||||||
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 {
|
||||||
@ -12,6 +13,7 @@ function Invoke-WPFUpdatesScan {
|
|||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Error "Failed to install PSWindowsUpdate module: $_"
|
Write-Error "Failed to install PSWindowsUpdate module: $_"
|
||||||
|
$sync.form.Dispatcher.Invoke([action] { $sync["WPFScanUpdates"].IsEnabled = $true })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -23,6 +25,7 @@ function Invoke-WPFUpdatesScan {
|
|||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Error "Failed to import PSWindowsUpdate module: $_"
|
Write-Error "Failed to import PSWindowsUpdate module: $_"
|
||||||
|
$sync.form.Dispatcher.Invoke([action] { $sync["WPFScanUpdates"].IsEnabled = $true })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,4 +61,7 @@ function Invoke-WPFUpdatesScan {
|
|||||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Error" -overlay "warning" })
|
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Error" -overlay "warning" })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$sync["WPFScanUpdates"].IsEnabled = $false
|
||||||
|
$sync["WPFUpdateSelectedInstall"].IsEnabled = $false
|
||||||
|
$sync["WPFUpdateAllInstall"].IsEnabled = $false
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user