Skip to content

Commit

Permalink
Merge pull request #2 from CodingWonders/cw-updgui-241113
Browse files Browse the repository at this point in the history
UpdGUI Enhancements for Version 1.0
  • Loading branch information
CodingWonders authored Nov 13, 2024
2 parents 045ec07 + 9f4b1fa commit 19effc0
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 11 deletions.
5 changes: 3 additions & 2 deletions aboutform.resources.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
'Button1.Name' = 'Button1'
'RichTextBox1.Text' = 'UpdGUI is a simple front-end written in PowerShell for the PSWindowsUpdate module.
Version: 0.1
Version: 1.0
- Programming: CodingWonders (https://www.github.com/CodingWonders)
- Idea: og-mrk (https://www.github.com/og-mrk)
This is a project in alpha, so feedback is very appreciated.'
- Feedback is appreciated! Report any issues you may encounter or suggest new ideas in the Issues page
- Do you want to contribute? Follow the contribution guidelines at the bottom of the README file'
'RichTextBox1.Name' = 'RichTextBox1'
}
}
24 changes: 21 additions & 3 deletions updgui.designer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ $Form1 = New-Object -TypeName System.Windows.Forms.Form
[System.Windows.Forms.Button]$Button2 = $null
[System.Windows.Forms.Label]$Label1 = $null
[System.Windows.Forms.Button]$Button3 = $null
[System.Windows.Forms.CheckBox]$CheckBox1 = $null
function InitializeComponent
{
$ListView1 = (New-Object -TypeName System.Windows.Forms.ListView)
Expand All @@ -21,6 +22,7 @@ $Button1 = (New-Object -TypeName System.Windows.Forms.Button)
$Button2 = (New-Object -TypeName System.Windows.Forms.Button)
$Label1 = (New-Object -TypeName System.Windows.Forms.Label)
$Button3 = (New-Object -TypeName System.Windows.Forms.Button)
$CheckBox1 = (New-Object -TypeName System.Windows.Forms.CheckBox)
$Form1.SuspendLayout()
#
#ListView1
Expand Down Expand Up @@ -98,10 +100,10 @@ $Button2.add_Click($Button2_Click)
#Label1
#
$Label1.Anchor = ([System.Windows.Forms.AnchorStyles][System.Windows.Forms.AnchorStyles]::Bottom -bor [System.Windows.Forms.AnchorStyles]::Left -bor [System.Windows.Forms.AnchorStyles]::Right)
$Label1.Font = (New-Object -TypeName System.Drawing.Font -ArgumentList @([System.String]'Arial',[System.Single]11.25,[System.Drawing.FontStyle]::Regular,[System.Drawing.GraphicsUnit]::Point,([System.Byte][System.Byte]0)))
$Label1.Location = (New-Object -TypeName System.Drawing.Point -ArgumentList @([System.Int32]492,[System.Int32]628))
$Label1.Font = (New-Object -TypeName System.Drawing.Font -ArgumentList @([System.String]'Trebuchet MS',[System.Single]11.25,[System.Drawing.FontStyle]::Regular,[System.Drawing.GraphicsUnit]::Point,([System.Byte][System.Byte]0)))
$Label1.Location = (New-Object -TypeName System.Drawing.Point -ArgumentList @([System.Int32]647,[System.Int32]628))
$Label1.Name = [System.String]'Label1'
$Label1.Size = (New-Object -TypeName System.Drawing.Size -ArgumentList @([System.Int32]677,[System.Int32]33))
$Label1.Size = (New-Object -TypeName System.Drawing.Size -ArgumentList @([System.Int32]522,[System.Int32]33))
$Label1.TabIndex = [System.Int32]2
$Label1.Text = [System.String]'Check console output for progress on update installation!'
$Label1.TextAlign = [System.Drawing.ContentAlignment]::MiddleCenter
Expand All @@ -120,15 +122,30 @@ $Button3.Text = [System.String]'About'
$Button3.UseVisualStyleBackColor = $true
$Button3.add_Click($Button3_Click)
#
#CheckBox1
#
$CheckBox1.Anchor = ([System.Windows.Forms.AnchorStyles][System.Windows.Forms.AnchorStyles]::Bottom -bor [System.Windows.Forms.AnchorStyles]::Left)
$CheckBox1.FlatStyle = [System.Windows.Forms.FlatStyle]::System
$CheckBox1.Font = (New-Object -TypeName System.Drawing.Font -ArgumentList @([System.String]'Tahoma',[System.Single]8.25,[System.Drawing.FontStyle]::Regular,[System.Drawing.GraphicsUnit]::Point,([System.Byte][System.Byte]0)))
$CheckBox1.Location = (New-Object -TypeName System.Drawing.Point -ArgumentList @([System.Int32]492,[System.Int32]628))
$CheckBox1.Name = [System.String]'CheckBox1'
$CheckBox1.Size = (New-Object -TypeName System.Drawing.Size -ArgumentList @([System.Int32]149,[System.Int32]33))
$CheckBox1.TabIndex = [System.Int32]4
$CheckBox1.Text = [System.String]' Verbose output'
$CheckBox1.UseVisualStyleBackColor = $true
#
#Form1
#
$Form1.ClientSize = (New-Object -TypeName System.Drawing.Size -ArgumentList @([System.Int32]1262,[System.Int32]673))
$Form1.Controls.Add($CheckBox1)
$Form1.Controls.Add($Button3)
$Form1.Controls.Add($Label1)
$Form1.Controls.Add($Button1)
$Form1.Controls.Add($ListView1)
$Form1.Controls.Add($Button2)
$Form1.ForeColor = [System.Drawing.SystemColors]::ActiveCaptionText
$Form1.MaximumSize = (New-Object -TypeName System.Drawing.Size -ArgumentList @([System.Int32]4096,[System.Int32]4096))
$Form1.MinimumSize = (New-Object -TypeName System.Drawing.Size -ArgumentList @([System.Int32]600,[System.Int32]240))
$Form1.StartPosition = [System.Windows.Forms.FormStartPosition]::CenterScreen
$Form1.Text = [System.String]'UpdGUI'
$Form1.ResumeLayout($false)
Expand All @@ -142,5 +159,6 @@ Add-Member -InputObject $Form1 -Name Button1 -Value $Button1 -MemberType NotePro
Add-Member -InputObject $Form1 -Name Button2 -Value $Button2 -MemberType NoteProperty
Add-Member -InputObject $Form1 -Name Label1 -Value $Label1 -MemberType NoteProperty
Add-Member -InputObject $Form1 -Name Button3 -Value $Button3 -MemberType NoteProperty
Add-Member -InputObject $Form1 -Name CheckBox1 -Value $CheckBox1 -MemberType NoteProperty
}
. InitializeComponent
62 changes: 56 additions & 6 deletions updgui.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,51 @@ $ListView1_ItemChecked = {
if ($ListView1.CheckedItems.Count -gt 0) {
$Button2.Enabled = $true
} else {
$Button2.Enabled = $false
$Button2.Enabled = $false
}
}
$ListView1_SelectedIndexChanged = {
if ($ListView1.CheckedItems.Count -gt 0) {
$Button2.Enabled = $true
} else {
$Button2.Enabled = $false
$Button2.Enabled = $false
}
}
$Button2_Click = {
# Install selected updates
if ($ListView1.CheckedItems.Count -gt 0) {
$CheckBox1.Enabled = $false
$Label1.Visible = $true
Invoke-InfoLogging "Installing selected updates. Please wait..."
Invoke-InfoLogging "While you're waiting, why not listen to some cheerful music? https://www.youtube.com/watch?v=QHdZjxrG35U"
$checkedUpdates = $ListView1.CheckedItems
foreach ($selLVI in $checkedUpdates) {
Invoke-InfoLogging "Installing update with name: `"$($selLVI.SubItems[4].Text)`" (KB Article ID: $($selLVI.SubItems[2].Text))..."
if ($selLVI.Subitems[2].Text -ne "") {
Get-WindowsUpdate -ComputerName "$($selLVI.SubItems[1].Text)" -KBArticleID $selLVI.SubItems[2].Text -Install -Confirm:$false
if ($CheckBox1.Checked -eq $true) {
Get-WindowsUpdate -ComputerName "$($selLVI.SubItems[1].Text)" -KBArticleID $selLVI.SubItems[2].Text -Install -Confirm:$false -Verbose
} else {
Get-WindowsUpdate -ComputerName "$($selLVI.SubItems[1].Text)" -KBArticleID $selLVI.SubItems[2].Text -Install -Confirm:$false
}
} else {
Get-WindowsUpdate -ComputerName "$($selLVI.SubItems[1].Text)" -Title "$($selLVI.SubItems[4].Text)" -Install -Confirm:$false
if ($CheckBox1.Checked -eq $true) {
Get-WindowsUpdate -ComputerName "$($selLVI.SubItems[1].Text)" -Title "$($selLVI.SubItems[4].Text)" -Install -Confirm:$false -Verbose
} else {
Get-WindowsUpdate -ComputerName "$($selLVI.SubItems[1].Text)" -Title "$($selLVI.SubItems[4].Text)" -Install -Confirm:$false
}
}
if ($?) {
Invoke-InfoLogging "Update with name `"$($selLVI.SubItems[4].Text)`" has been successfully installed"
$ListView1.Items.Remove($selLVI)
} else {
Invoke-InfoLogging "Update with name `"$($selLVI.SubItems[4].Text)`" has not been installed"
Invoke-InfoLogging "Error information: $_.Exception.Message"
Invoke-InfoLogging "Error information: $_.Exception.Message"
}
}
$Label1.Visible = $false
$CheckBox1.Enabled = $true
} else {
[System.Windows.Forms.MessageBox]::Show("Please select updates to install and try again.")
[System.Windows.Forms.MessageBox]::Show("Please select updates to install and try again.")
}
}
$Form1_FormClosed = {
Expand Down Expand Up @@ -95,18 +106,57 @@ function Check-PSWindowsUpdate {
Import-Module PSWindowsUpdate
if ((Get-Module -Name PSWindowsUpdate).Count -lt 1) { throw }
}
Invoke-InfoLogging "Either the PSWindowsUpdate module has been successfully imported or no actions had to be done in the first place. Continuing startup..."
}
catch {
Invoke-InfoLogging "Unable to check PSWindowsUpdate. Error: $($_.Exception.Message). Exiting..."
exit 1
}
}

function Show-StartupGraphic {
# Show a cool graphic on startup
Write-Host -NoNewline "`n`n"
Write-Host " dddddddd "
Write-Host " UUUUUUUU UUUUUUUU d::::::d GGGGGGGGGGGGGUUUUUUUU UUUUUUUUIIIIIIIIII"
Write-Host " U::::::U U::::::U d::::::d GGG::::::::::::GU::::::U U::::::UI::::::::I"
Write-Host " U::::::U U::::::U d::::::d GG:::::::::::::::GU::::::U U::::::UI::::::::I"
Write-Host " UU:::::U U:::::UU d:::::d G:::::GGGGGGGG::::GUU:::::U U:::::UUII::::::II"
Write-Host " U:::::U U:::::Uppppp ppppppppp ddddddddd:::::d G:::::G GGGGGG U:::::U U:::::U I::::I "
Write-Host " U:::::D D:::::Up::::ppp:::::::::p dd::::::::::::::dG:::::G U:::::D D:::::U I::::I "
Write-Host " U:::::D D:::::Up:::::::::::::::::p d::::::::::::::::dG:::::G U:::::D D:::::U I::::I "
Write-Host " U:::::D D:::::Upp::::::ppppp::::::pd:::::::ddddd:::::dG:::::G GGGGGGGGGG U:::::D D:::::U I::::I "
Write-Host " U:::::D D:::::U p:::::p p:::::pd::::::d d:::::dG:::::G G::::::::G U:::::D D:::::U I::::I "
Write-Host " U:::::D D:::::U p:::::p p:::::pd:::::d d:::::dG:::::G GGGGG::::G U:::::D D:::::U I::::I "
Write-Host " U:::::D D:::::U p:::::p p:::::pd:::::d d:::::dG:::::G G::::G U:::::D D:::::U I::::I "
Write-Host " U::::::U U::::::U p:::::p p::::::pd:::::d d:::::d G:::::G G::::G U::::::U U::::::U I::::I "
Write-Host " U:::::::UUU:::::::U p:::::ppppp:::::::pd::::::ddddd::::::dd G:::::GGGGGGGG::::G U:::::::UUU:::::::U II::::::II"
Write-Host " UU:::::::::::::UU p::::::::::::::::p d:::::::::::::::::d GG:::::::::::::::G UU:::::::::::::UU I::::::::I"
Write-Host " UU:::::::::UU p::::::::::::::pp d:::::::::ddd::::d GGG::::::GGG:::G UU:::::::::UU I::::::::I"
Write-Host " UUUUUUUUU p::::::pppppppp ddddddddd ddddd GGGGGG GGGG UUUUUUUUU IIIIIIIIII"
Write-Host " p:::::p "
Write-Host " p:::::p "
Write-Host " p:::::::p "
Write-Host " p:::::::p "
Write-Host " p:::::::p "
Write-Host " ppppppppp "
Write-Host -NoNewline "`n`n"
Write-Host " A simple front-end for PSWindowsUpdate. "
Write-Host " Version 1.0 "
Write-Host " Programming: https://www.github.com/CodingWonders "
Write-Host " Idea: https://www.github.com/og-mrk "
Write-Host ""
Write-Host " ASCII graphic: http://patorjk.com/software/taag "
Write-Host ""
}

Clear-Host

# Set execution policy for the process scope
Set-ExecutionPolicy Bypass Process

Show-StartupGraphic

Check-PSWindowsUpdate

Add-Type -AssemblyName System.Windows.Forms
Expand Down
1 change: 1 addition & 0 deletions updgui.resources.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
& { $BinaryFormatter = New-Object -TypeName System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
@{
'Button2.Name' = 'Button2'
'CheckBox1.Name' = 'CheckBox1'
'ColumnHeader3.Name' = 'ColumnHeader3'
'ListView1.Name' = 'ListView1'
'ColumnHeader5.Name' = 'ColumnHeader5'
Expand Down

0 comments on commit 19effc0

Please sign in to comment.