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?
Best Answer
You can use a do{...}until()
with [console]::KeyAvailable
do{test-Connection -ComputerName google.com -Count 1Start-Sleep -Seconds 1}until([Console]::KeyAvailable)