
PowerShellから
・対象PCへ
・Pingコマンドを実行
できます!
コード
ここでは例として
・コンピューター名(ホスト名)が「serverhost」のPCへ
・Pingコマンドを実行して結果を取得
します。
※「serverhost」は私のネットワーク上に存在するPCの「コンピューター名(ホスト名)」です。
# 対象PCを指定
# 対象PCはIPアドレス or コンピューター名(ホスト名)で指定
$targetServer = "serverhost"
$ws = New-Object -ComObject Wscript.Shell
try
{
# Ping実行
$res = Test-Connection $targetServer -Quiet -Count 1
# 結果
if($res) {
$ws.popup("Ping成功")
} else {
$ws.popup("Ping失敗")
}
}
catch
{
$ws.popup("エラー : " + $PSItem)
}
実行結果
対象PCへPingコマンドを実行し、結果を取得できました。
●対象PCが起動している かつ ネットワークに繋がっている場合
Pingが成功しました。

●対象PCが起動している かつ ネットワークに繋がっていない場合
●対象PCが起動していない場合
Pingが失敗しました。

参考
上記のコードで使用した以下の詳細は、公式サイトをご確認ください。
●「Test-Connection」コマンドレット