Textbox to display lines of text per section of script without clearing other lines. (Like a EventLog)


I have been trying to learn PowerShell and have gotten on really well. I wanted to attempt to create GUI for a script that I use. But i want the textbox to display the progress of the script for example

Created User Account - Complete
Screen Lock - Complete
and so on.

I have Window with a TextBox. But even tho I have enabled multiple lines. the last text is removed.

How can I stop it from removing the former text and just for it to add an extra line with the text.

    $eventlog.Text = "test 1"
Start-Sleep -Seconds 10
$eventlog.Text = "Test 2"

the code above will remove the test 1 and replace it with Test 2 I am trying to get it to display both. The entries would be throughout the script to display the progress.

Any help or pointers would be great. PS I have not added the full script yet as I thought the best place to start is the text box.

Use the AppendText() method.

$eventLog.AppendText("`r`nI will appear on the next line.")
1 Like

Not sure how fancy you want to get, but I added a Status Bar to a from in one of my projects and then display the verbage in the StatusBar, similar to the StatusBar on a browser.

$statusBar = New-Object System.Windows.Forms.StatusBar
$statusBarPanel = New-Object System.Windows.Forms.StatusBarPanel
$statusBarPanel.AutoSize = 'Spring'
$statusBarPanel.Text = 'Ready ..'
$statusBarPanel.ToolTipText = 'Tooltip text goes here'
$statusBar.ShowPanels = $True

Then, add it to your form:


Then, to change the message/text:

$statusBarPanel.Text = 'Have a great day'