Created
April 23, 2025 13:36
-
-
Save zulhfreelancer/2a587cdff3bf2cc7743110e15a2c90d2 to your computer and use it in GitHub Desktop.
Revisions
-
zulhfreelancer created this gist
Apr 23, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ This PowerShell script will continuously prints the current time and pings an IP address. It will run in a loop until you press `Ctrl+C` to stop it. ```powershell # Replace <IP> with target host IP address try { while ($true) { $timestamp = Get-Date -Format 'yyyy-MM-dd HH:mm:ss' $pingResult = ping <IP> -n 1 if ($pingResult -match "Reply from") { Write-Host "$timestamp - Host is up" } else { Write-Host "$timestamp - Host is down" } Start-Sleep -Seconds 1 } } catch { Write-Host "Script interrupted." } ```