Hello,
Voici un petit script rapide pour effectuer un ping et afficher le résultat en console, avec horodatage et affichage des itération :
# Change this variable to determine the ping destination $destination = "google.com" # Change this variable to determine how many itteration should be made $iteration = "9" # Do not change anything beyond this point (or simply add text logging if necessary, for example via a write-log function) [int]$i = 1 do { $date = get-date -Format "dd-MMMM-yyyy_hh'h'ss" $ping = $null $ping = Test-Connection -ComputerName $destination -Quiet -count 2 if ($ping) { Write-Host -BackgroundColor Green -ForegroundColor White -Object "$date : PING OK (iteration $i)" } else { Write-Host -BackgroundColor Red -ForegroundColor White -Object "$date : PING NOK (iteration $i)" } $i++ }until($i -gt $iteration)
Le résultat :
Et voilà 🙂 !