I would like to execute below command continuously until a key is pressed. As an example:
Test-NetConnection -ComputerName google.com -Port 80
How can I do this?
You can use a do{...}until() with [console]::KeyAvailable
do
{
test-Connection -ComputerName google.com -Count 1
Start-Sleep -Seconds 1
}
until([Console]::KeyAvailable)