none
Powershell Gui tool created .But Out put is coming for only one server RRS feed

  • Question

  • Hi All,

    I Have created GUI tool  for BAU tasks..Its is working fine for single system

    but if i add one more server.it is not taking..Need  to convert the string in into array..and needs to get out put for all servers..

    I am sharing the code under ping function..Please share the code that works..

    #Ping
    function Pinginfo{
    $wks=$InputBox.text;
    $pingResult= ping $wks |fl| out-string;
    $outputBox.text=$pingResult}


    • Edited by Mylavarapu Satyanarayana Saturday, July 22, 2017 3:43 AM err
    • Moved by Bill_Stewart Wednesday, September 13, 2017 9:03 PM This is not "fix/debug/rewrite my script for me" forum
    Saturday, July 22, 2017 3:41 AM

All replies

  • "$inputbox.Lines" contains the lines as an array.


    \_(ツ)_/

    Saturday, July 22, 2017 9:06 AM
  • yes i know..can you give little example to convert array in next line foreach
    Saturday, July 22, 2017 3:26 PM
  • $inputbox.Lines | 
         Foreach-Object{
              Write-Host $_
        }


    \_(ツ)_/

    Saturday, July 22, 2017 3:29 PM
  • function Pinginfo{

    $computers=$InputBox.text.Split("`n")
    $info= @()
    foreach ($c in $computers)
    {
    $res= ping $c -n 2 |Out-String
    Write-Host $res
    $info+=$res
    }
    $outputBox.Appendtext("{0}`n"-f $info)
    }

    i have take help of above code..but its is taking for only one value..not sure what went wrong

    Sunday, July 23, 2017 3:45 PM
  • foreach($c in $inputbox.Lines){ 
           $outputbox.Lines += Test-Connection $c -Count 2 | Out-String
           [System.Windows.Forms.Application]::DoEvents()
    }
         


    \_(ツ)_/


    • Edited by jrv Sunday, July 23, 2017 3:59 PM
    Sunday, July 23, 2017 3:57 PM
  • You can also do that with ping although I use Test-Connection and a DataGridView.

    $buttonPingAll_Click={
    	foreach($line in $InputBox.Lines){
    		$OutputBox.Lines += ping $line -n 2
    		$outputbox.Select($OutputBox.Text.Length - 1,0)
    		$OutputBox.ScrollToCaret()
        }
    }
    


    \_(ツ)_/

    Sunday, July 23, 2017 4:16 PM