Windows Updates - Output to textbox

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 10 months and 2 weeks old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
DReAMeRnz
Posts: 1
Last visit: Wed Jan 03, 2024 2:52 pm

Windows Updates - Output to textbox

Post by DReAMeRnz »

Hi all,

I wrote a powershell script that we can use in our remote access tool to run Windows Updates without bothering the client, then just email them and request that they reboot.

In Powershell, I get to see the verbose output of the script, mainly the Get-WindowsUpdate command and it gives me a verbose output with key information.
  1. VERBOSE: VDFF0002L (20/12/2023 3:16:10 pm): Connecting to Microsoft Update server. Please wait...
  2. VERBOSE: Found [18] Updates in pre search criteria
  3. VERBOSE: Found [1] Updates in post search criteria
  4.  
  5. VERBOSE: Accepted [1] Updates ready to Download
  6. VERBOSE: Downloaded [1] Updates ready to Install
I've started converting my script into a GUI and have set it up to show the available updates and prompt to continue, I would like to know if it's possible to then output the verbose into my RichTextBox?
  1. if ([System.Windows.Forms.MessageBox]::Show("Continue?", "Would you like to install these updates?", [System.Windows.Forms.MessageBoxButtons]::OKCancel) -eq "OK")
  2.         {
  3.             $richtextbox_Output.Clear()
  4.             $richtextbox1.SelectionColor = 'Blue'
  5.             $richtextbox1.AppendText("Installing updates... `n")
  6.             Get-WindowsUpdate -NotCategory "Drivers" -NotTitle "Windows 11" -Verbose -Install -AcceptAll -IgnoreReboot
  7.         }
This topic is 10 months and 2 weeks old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked