Compare commits

..

2 Commits

Author SHA1 Message Date
2e2cf449a4 Merge pull request 'Minor changes in Windows scripts' (#3) from v1 into master
Reviewed-on: https://www.cainet.info/git/cai/CAI-Watchdog/pulls/3
2022-06-27 09:37:45 +03:00
Alexander I. Chebykin
577ad19b9f Minor changes in Windows scripts
Minor changes in Windows scripts
2022-06-27 09:35:30 +03:00
2 changed files with 16 additions and 18 deletions

View File

@ -1,11 +1,9 @@
Function Send-Mail { $EmailFrom = "yourmailadress@somedomain.com"
$EmailFrom = "yourmailadress@somedomain.com" $EmailTo = $args[0]
$EmailTo = $args[0] $Subject = $args[1]
$Subject = $args[1] $Body = $args[0]
$Body = $args[0] $SMTPServer = "smtp.somedomain.com"
$SMTPServer = "smtp.somedomain.com" $SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587) $SMTPClient.EnableSsl = $true
$SMTPClient.EnableSsl = $true $SMTPClient.Credentials = New-Object System.Net.NetworkCredential("usr", "pass");
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential("usr", "pass"); $SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)
}

View File

@ -1,10 +1,10 @@
Function Send-Telegram { Param([Parameter(Mandatory=$true)][String]$Message)
Param([Parameter(Mandatory=$true)][String]$Message)
$Telegramtoken = "Your_Telegram_Token" $Telegramtoken = "Your_Telegram_Token"
$Telegramchatid = "Your_Telegram_Chat_ID" $Telegramchatid = "Your_Telegram_Chat_ID"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $Message = $args[0]
$Response = Invoke-RestMethod -Uri "https://api.telegram.org/bot$($Telegramtoken)/sendMessage?chat_id=$($Telegramchatid)&text=$($Message)" [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
}
$Response = Invoke-RestMethod -Uri "https://api.telegram.org/bot$($Telegramtoken)/sendMessage?chat_id=$($Telegramchatid)&text=$($Message)"