none
How to Use muliple lines input from textbox-powershell gui winforms RRS feed

  • Question

  • Hi,

    I am trying to create a PowerShell GUI tool to work on basic server administration.

    well my requirement i want to initiate PowerShell command on multiple servers line by line in input text box. When is used below function  as an example . it is giving for only one server. If we add more servers it wont give the first server output..Iam posting my code. Please help me out..

    #########################################

    function uptime {
    $outputBox.Clear()
    $computers=$InputBox.text.Split("`n")
    foreach ($computer in $computers)
    {
    $infouptime =  get-uptime $computer ft -AutoSize |out-string
    Write-Host $infouptime
    $outputBox.Appendtext("{0}`n" -f $infouptime)
    }
       } 

    #########################################

    Output

    Sunday, August 6, 2017 7:40 AM

Answers

All replies

  • foreach($line in $textbox.lines){
         Write-Host $line
    }

    \_(ツ)_/

    Sunday, August 6, 2017 4:43 PM
  • That's working  very perfectly. I want say big thanks to JRV..you always helps every one.

    I struck in this  problem and finally you pulled me up.

    Thanks again.

    Wednesday, August 9, 2017 12:31 PM
  • I have one more request master. How can I get the output in good format in the output text box..

    example: if you see the  screenshot, the format is not came  nicely.where as if run the same in ISE it looks good.

    Please advice how can I get the output  which looks good.



    Wednesday, August 9, 2017 12:39 PM
  • i have changed the default font and decreased the font size and it is working fine
    Wednesday, August 16, 2017 11:35 AM