Using PowerShell to put ping frames as a list on monitor

In Summary: “Each morning I run a PowerShell script the produces “Ping Frames”. The problem is that the ‘ping frames’ just open willy-nilly and stack on top of each other. I simply want the ‘ping frames’ to be in a nice column on the right hand side of my monitor. Two columns if too many “ping frames” to fit monitor.

Each morning I run this script:

$thelist = import-csv “\gofs\Departments\Computer Operations\TicketMaker\eplum_csv\Currentscale.csv”

ForEach ($item in $thelist)
{
$StoreNum = $item.(“Store”)
$DeptNum = $item.(“Department”)
$IPNodes = $item.(“IP Address")
$ScaleAddress = $item.(“Scale Address”)
$Action = $item.(“Active")
$Rsn = $item.(“Inactive Reason")

if ($StoreNum -ne 0 -and $StoreNum -ne 187 -and $StoreNum -ne 188)
{   
   if ($Action -eq "No")
   {    
       if ($Rsn -eq "" -or $Rsn -eq "Scale was set to inactive - exceeded MaxBatchRetryHours=1")
       {
          foreach ($IP in $IPNodes)
          {
             if (Test-Connection -IPAddress $IP -Count 1 -ErrorAction SilentlyContinue)
             {
                #Write-Host "$IP is UP" -ForegroundColor Blue;
             }
             Else
             {
                Write-Host "Store: $StoreNum Dept: $DeptNum IPaddress:$IP is Down" -ForegroundColor Red;        
                start-process cmd -ArgumentList  "/C","mode con:cols=55 lines=2 && title Store: $StoreNum IP: $IP && ping $IP -t"
                
             }
          }    
       }     
   } 
   
}

}
Write-Host “If Dave can’t do it, nobody can!” -ForegroundColor Green;
Start-Sleep -s 15

"The purpose of the script is to “hold” a constant ping until the “ip address becomes pingable” The problem is when I run the script the frames just stack on top of each other. What I want PowerShell to do is open each one and place it on the right hand side of monitor as a list, not stacked on top of each other. I cannot figure out how to “move them”. I am extremely new to PS and this is my very first project so any help would be greatly appreciated. Thanks!!!

ping_frames

That’s more of a Windows problem than PowerShell. Stacking windows is a OS behavior. You’d have to track those windows and use windows native libraries and pinvokes to arrange to them or, easier, but still not easy build a MDI dot NET form and embed console windows and arrange them

2 Likes

Super Dave,
Welcome to the forum. :wave:t3:

There might be a better way than flooding your desktop with a lot of individual windows for each individual IP address!? :wink:

Regardless of that … When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.

Thanks in advance

How to format code in PowerShell.org <---- click! :point_up_2:t3: :wink:

1 Like

multithreading - How to Multithread PowerShell Ping Script - Stack Overflow

engrit-illinois/Ping-All: Ping-All is a PowerShell module to allow you to ping multiple computers with a single command, asynchronously. (github.com)

2 Likes

Adding to the Ping-all suggestion, add the item status to an array and display/refresh the status in your “one-panel” periodically (every 5-10 seconds) - not sure how many devices your have or how often you want updates. I’ve found some significant delays to responses from hosts, so your “one panel” could be refreshed while waiting for the slower (or delayed) devices.

I think the delay has to do with how many async calls are made simultaneously, but not quite sure.