Windows 8에서는 Test-NetConnection클래식 ping및 tracert도구 와 유사한 기능을 사용 하고 원격 시스템 포트의 상태를 확인할 수 있습니다. 불행히도에 대한 옵션 Test-NetConnection은 대체 도구에 비해 상대적으로 제한적입니다. 따라서 연속 모니터에는 적합하지 않습니다. 다행히 PowerShell은 매우 스크립팅 가능합니다. 다음은 하나의 라이너 (기술적으로는 여러 개의 라인이 하나로 압축되어 있음)로 포트의 가용성을 지속적으로 테스트하고 타임 스탬프 결과를 콘솔에 인쇄하는 것입니다.
cls;1..8|%{""};for(){$x=tnc 192.168.0.1 -Po 80;"$(Get-Date) $($x.TcpTestSucceeded)"}
다음은 작동중인 스크립트의 스크린 샷입니다. cls;1..8|%{""};기술적으로 필요하지 않더라도 스크립트를 시작한 이유를 여기서 확인할 수 있습니다 . 또한 Test-NetConnectionLAN 연결 상태에서도 매번 실행 하는 데 약 9-10 초가 걸린다는 것을 알 수 있습니다 .

다음은 주석 처리 된 여러 줄 버전의 스크립트입니다. 이것은 동일한 코드이며, 연습이 포함되어 있습니다.
# CLS is a built-in alias for Clear-Host.
# This clears any pre-existing output from the console so we can start ours from the top.
cls;
# This takes the integers from 1 through 8 and pipes them to a ForEach-Object loop.
# (The percent symbol, "%", is a built-in alias for ForEach-Object.)
# Putting just a pair of double-quotes in the script block outputs a single blank line.
# Effectively, this line of script just outputs 8 blank lines.
# While Test-NetConnection runs, it puts a status display on the top 8 lines of the console.
# So, we're using this to make our output start below that level in order to be visible.
1..8|%{""};
# This begins an infinite for loop. It will run until aborted by the user.
# (e.g.: With CTRL+C)
# Note: Due to the way Test-NetConnection operates, the abort may take a few seconds to process.
for(){
# TNC is a built-in alias for Test-NetConnection.
# -Po is a shorthand for the -Port parameter name.
# PowerShell allows shortening of parameter names down to as few characters are needed to uniquely identify the parameter.
# This tests for connectivity to port 80 at 192.168.0.1 and puts the results in $x.
$x=tnc 192.168.0.1 -Po 80;
# The last step here is to output a timestamp, and the results.
# Double-quotes allow for per-processing certain elements before including them in an output string.
# Encapsulating script blocks with $(), within the double-quotes, lets us put their results directly in the output string.
# So, the first part gets the date and time for the start of the output.
# Then, with a space to separate it, the TcpTestSucceeded property of $x is retrieved and put at the end.
"$(Get-Date) $($x.TcpTestSucceeded)"
}
내가 원하는만큼 깨끗하고 단순하지는 않지만 일을합니다. 나는 확실히 곧 그것을 암기 할 것으로 기대하지는 않지만 명령과 PowerShell 기본 사항을 이해 하면 즉시 재구성 하는 것이 상대적으로 쉽습니다.
조금 더 간단한 것으로, 포트를 계속 확인하고 포트가 작동 중임을 알리는 것을 멈 추면 다음을 사용할 수 있습니다.
while((tnc 192.168.0.1 -Po 80).TcpTestSucceeded -eq $False){};Get-Date
여기서는 while 루프를 사용하여 포트가 다운되어있는 동안 계속 포트를 다시 테스트합니다. 포트에 성공적으로 연결되면 while 루프가 종료되고 Get-Date가 시간을보고합니다. 또한 Test-NetConnection루프가 실행되는 동안 경고 메시지 가 표시됩니다. 이는 전체 결과를 실제로 일반 출력으로 보내기 전에 경고 출력 채널을 사용하여 핑 또는 포트 연결이 실패 할 때보고하기 때문입니다.
불행히도 Test-NetConnectionWindows 8 미만을 실행하는 시스템에서는 사용할 수 없습니다. 따라서 이것은 내가 기대했던 교차 호환성이 부족합니다. 그래도 지금은 아무것도 아닌 것보다 낫습니다.