I made the skeleton of the GUI and all looks great and now I just have to get some code in. I have a multiline text box where users can type in multiple computer names and a Run box. I have the output going to a GridView using the Out-GridView cmdlet.
For testing purposes, I am just running test-connection to see if the output looks ok and it does when I enter one computer, BUT, when I enter multiple computers it sees it as one big computer name and it errors out saying that “Test1ComputerTest2ComputerTest3Computer is offline”.
How do I get PowerShell Studio to see each computer on each line as a separate computer in a multiline text box without it seeing it all as one string?
You could argue that a GUI based application trying to parse a multiline textbox and convert its content into an array instead of using the relatively standard combination of a single line textbox, add and remove buttons, and a list box is tacky…
Regards your code, another possible way of doing this would be something like below. Might need a bit of tidying up, but sure you’ll get the gist of it.
You can do that combination I mentioned pretty straightforwardly BTW. The Listbox.Items collection can then be parsed in your for…each script for your Test-Connection scriptblock to execute.
Drag two buttons, a textbox, and a listbox item onto your form [on the basis that you’ve already the normal OK, Cancel buttons in place]
Rename the text on the textboxes to Add and Remove
Configure your add/remove buttons as the following respectively, replacing $lstComputers with the name of the listbox
Great job. Sir Ask Alot, you can also get help on the PowerShell Studio forum. If you post there and don’t get a quick or helpful answer, be sure to ping me at juneb@sapien.com.
Thanks!
June
June Blender
Technology Evangelist
SAPIEN Technologies, Inc.