0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

毎日1回YahooにPingを打つだけのお仕事(別冊)

Posted at

この記事は

前回記事(↑)の補足の記事

ExPingではNG時の動作として、オプションに4つの引数が使える

%n  ・・・  対象アドレス
%d  ・・・  日時
%s  ・・・  ステータス
%e  ・・・  備考

image.png

これをバッチで捕捉し、PowerShellに渡すことで
死活監視用のメールに情報をのせることができる(ログから情報を拾ってこなくとも)

バッチ

-Fileで実行するPowerShellスクリプトを指定し、そのあとに続けてExPingから渡ってきた4つの引数を書く

taskWithArgs.bat
%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -ExecutionPolicy Unrestricted -File .\mainWithArgs.ps1 %1 %2 %3 %4

PowerShell

mainWithArgs.ps1
Write-Host $args[0]
Write-Host $args[1]
Write-Host $args[2]
Write-Host $args[3]
return

実行結果

image.png

受信メール内容

image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?