You can’t do what you are after with just what you have.
You need to have conditional code to check for that.
You also, Don’t want to make this endless/infinite loop check. Thus, look at using a DoWhile for the criteria you are after and exit after a certain number of tries.
Personally, I am not really sure why you want to do it this way. Either the machine responds or it does not, and move on. Sure, you could have a machine have a response hiccup, but just report that and move on.
You could do the later and try the list again, after the main effort completes.
Also, what you are using is not going to return what you say you are after.
Why are you using the .Net name space vs using the built-in cmdlets…
And just taking action on the success response. Yes, you can use those in an async fashion as well.
Lastly, there are lots of examples of using PowerShell as a ping sweeper, all over the web. Just search for them.
‘powershell ping fast’
As far as the progress bar part. Look to the…
# get function / cmdlet details
Get-Command -Name Write-Progress -Syntax
(Get-Command -Name Get-ADUser).Parameters.Keys
Get-help -Name Write-Progress -Full
Get-help -Name Write-Progress -Online
Get-help -Name Write-Progress -Examples
… cmdlet help file for usage details, or use one of the models via the MS powershellgallery.com resources.
Find-Module -Name '*progress*' | Format-Table -AutoSize
Version Name Repository Description
------- ---- ---------- -----------
0.132 PoshProgressBar PSGallery A module for creating WPF progress bars using XAML and the Material Design Toolkit by Butchers Boy
1.1 psInlineProgress PSGallery Inline Progress Bar for PowerShell
0.21 write-ProgressEx PSGallery Write-ProgressEx extends the functionality of the standard cmdlet. Write-ProgressEx is a powershell advanced function...