Created
May 25, 2018 18:04
-
-
Save the-takeo/286da4d8f1d5764244fa4d1e0ce2e293 to your computer and use it in GitHub Desktop.
TaskCheck
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
Dim mFrom | |
Dim mTo | |
Dim SmtpSvr | |
mFrom = "From@From.com" | |
mTo = "To@To.com" | |
SmtpSvr = "SmtpServer" | |
Dim Subject | |
Dim TextBody | |
Subject = Wscript.Arguments(0) | |
TextBody = Wscript.Arguments(1) | |
Dim oMsg | |
Set oMsg = CreateObject("CDO.Message") | |
oMsg.From = mFrom | |
oMsg.To = mTo | |
oMsg.Subject = Subject | |
oMsg.TextBody = TextBody | |
oMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/" + "sendusing")= 2 | |
oMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/" + "smtpserver")= SmtpSvr | |
oMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/" + "smtpserverport")=25 | |
oMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/" + "smtpusessl")=False | |
oMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/" + "smtpauthenticate")=0 | |
oMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/" + "sendusername")="user@gmail.com" | |
oMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/" + "sendpassword")="password" | |
oMsg.Configuration.Fields.Update | |
oMsg.Send |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Task = (schtasks /query /s localhost /tn "TaskName" /v /fo csv | ConvertFrom-Csv) | |
if($Task.状態 -ne "準備完了"){ | |
cscript SendMail.vbs "Taskの状態異常通知" "Taskが実行中か、または異常な状態です。タスクスケジューラからTaskの「状態」を確認してください。" | |
}else{ | |
Write-Output 'No announcement' | |
} | |
if($Task.前回の結果 -ne 0){ | |
cscript SendMail.vbs "Taskの結果異常通知" "Taskが異常終了しています。タスクスケジューラからTaskの「前回の実行結果」を確認してください。" | |
}else{ | |
Write-Output 'No announcement' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment