Mikey
Mikey

Reputation: 133

Copying GUI TextBox data to a text file

I know this a simple solution but I can not figure out the syntax. I'm trying to take information from a multi-line TextBox and place it in a file when a button click happens. Here is where I'm at currently as an incomplete idea of where I'm going with it. The problem is I want to take a list of Machines from a GUI text box and place it into a text file.

$button.add_button(
    Get-Content $AddButton.TEXT | Foreach-Object {" I want to pipe into a c:\temp\PROD\Machines.txt"})

Any suggestions?

Thanks

Upvotes: 0

Views: 3447

Answers (1)

BartekB
BartekB

Reputation: 8650

Really not sure were I should start... ;)

  • I guess method is Add_Click
  • if $AddButon is your TextBox - you can access property directly rather than use Get-Content cmdlet
  • I would just use Out-File

Code:

$button.Add_Click({
    $AddButton.Text | Out-File c:\temp\PROD\Machines.txt
})

Not tested.

Upvotes: 2

Related Questions