POWERSHELL PINGを指定IPに出し続ける、グリッドビューで確認
6627 ワード
# 黒い画面を閉じる
powershell -WindowStyle Hidden -command "exit"
# INPUTBOXのおまじない
[void][System.Reflection.Assembly]::Load("Microsoft.VisualBasic, Version=8.0.0.0, Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a")
# pingを実行する宛先を指定する
$targets = [Microsoft.VisualBasic.Interaction]::InputBox("IPを入力してください(例)10.10.10.10","pingを出し続けます")
# 設定
# pingを実行する間隔(ミリ秒)
$interval = 500
# 繰り返し数
$repeat = 100
@(1..$repeat) | foreach {
$targets | foreach {
# 間隔をあけるためのsleep
Start-Sleep -Milliseconds $interval
try {
# ping実行
$tc = Test-Connection $_ -count 1 -ErrorAction Stop
#結果の格納
$result = "○"
} catch [Exception] {
# 失敗した場合
$result = "×"
}
# 現在時刻
$datetime = Get-Date -F "yyyy/MM/dd HH:mm:ss.fff"
# CSV形式で結果情報を作成
$row = $result + "," + $datetime + "," + $tc.Address + "," + $tc.ResponseTime
# CSVからオブジェクトを出力
$row | ConvertFrom-Csv -Header @("Result","DateTime","Target","ResponseTime(ms)")
}
} | Out-GridView -Title "Ping Results" # グリッドビューを表示する
Author And Source
この問題について(POWERSHELL PINGを指定IPに出し続ける、グリッドビューで確認), 我々は、より多くの情報をここで見つけました https://qiita.com/itakura1984/items/ea21853e267e9cd74c25著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .