rekabping.psm1

function rekabping {

    param(
        [string]$Target = "8.8.8.8",
        [int]$Interval = 1
    )

    Write-Host "rekabping started for $Target"
    Write-Host "Press Ctrl+C to stop"
    Write-Host ""

    while ($true) {

        $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"

        $result = ping.exe -n 1 $Target |
            Select-String "Reply from|Request timed out|Destination host unreachable|General failure"

        if ($result -match "Reply") {
            Write-Host "$timestamp | $result" -ForegroundColor Green
        }
        else {
            Write-Host "$timestamp | $result" -ForegroundColor Red
        }

        Start-Sleep -Seconds $Interval
    }
}

Export-ModuleMember -Function rekabping