發表文章

目前顯示的是 6月, 2024的文章

[維修小札] 如何持續測試網路PING值並且記錄 How to continuously test network ping values and record them

圖片
大概是這樣的功能,他會持續監測,並且記錄PING值。 如果有timeout,會另存檔案作紀錄。 The functionality is like this:        it continuously monitors and records ping values.  The output file name is ping_log.txt.  If there is a timeout, it saves the record in a separate file, ping_error_log.txt. 先建立一個純文字檔案,並且將下面程式碼貼入裡面。 然後將附檔名改成.ps1 First, create a plain text file and paste the following code into it.  Then, change the file extension to .ps1. ############################################################ $OutputFile = "ping_log.txt" $ErrorFile = "ping_error_log.txt" $PingTarget = "168.95.1.1" while ($true) {     $PingResult = Test-Connection -ComputerName $PingTarget -Count 1 -ErrorAction SilentlyContinue     $Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"     if ($PingResult) {         $LogEntry = "$Timestamp `t $($PingResult.Address) `t Time=$($PingResult.ResponseTime)ms `t TTL=$($PingResult.Ttl)"          ...