monitor_start.batをタスクスケジューラに登録
monitor_start.bat
@echo off
echo Bttery Check
rem Incoming WebhookのURLを格納
set URL="★Teamsのwebhook URL"
set POSTTEXT=Battery Post
cscript.exe /Nologo monitor_battery.vbs
echo %ERRORLEVEL%
curl.exe -H "Content-Type:application/json" -d "{'text':'%POSTTEXT% %ERRORLEVEL% Percent'}" %URL%
monitor_battery.vbs
'---------------------------------------------------
' ノートPCのバッテリ算容量を取得する
' usage: cscript /Nologo バッテリ容量.vbs
'---------------------------------------------------
Set rows = GetObject("winmgmts:\\.\root\cimv2").ExecQuery("Select * from Win32_Battery",,48)
For Each row in rows
Wscript.Echo row.EstimatedChargeRemaining
Wscript.Quit(row.EstimatedChargeRemaining)
Next