Cobian Backup и отправка сообщений в Telegram

, . () , Cobian Backup. , , .







, , - ( log ) telegram.







Telegram, Cobian Backup — . Telegram — , . — , . — . email .







Telegram



. Cobian Backup : " 2017-05-31 12:11 . : 0, : 3893, : 3893, : 2,43 GB ". . , — .







PowerShell. , .







$chat_id = 'chat_id' #  id ,     .     ,   . 
$date=get-date -uformat "%Y-%m-%d" #     
$text = get-content -Path ('c:\Program Files (x86)\Cobian Backup 11\Logs\log '+$date+'.txt') -Encoding UTF8 # ,    cobian backup
$token = 'token' # ,     
[string]$text=$text[$text.count-2] #  

#    
$payload = @{
    "chat_id" = $chat_id;
    "text" = "$text";
    "parse_mode" = 'HTML';
}

Invoke-WebRequest `
    -Uri ("https://api.telegram.org/bot{0}/sendMessage" -f $token) `
    -Method Post `
    -ContentType "application/json;charset=utf-8" `
    -Body (ConvertTo-Json -Compress -InputObject $payload)
      
      





Cobian Backup



, Cobian Backup , . , — — — . — Cobian Backup PowerShell. — BAT. BAT







TIMEOUT /T 5 /NOBREAK
%SystemRoot%\System32\WindowsPowerShell\v1.0\PowerShell.exe -ExecutionPolicy ByPass -command "C:\ToTelegram.ps1"
      
      





ToTelegram.ps1 — , PowerShell. bat . "." BAT .







, . - .







P.S. , , - .








All Articles