From 577ad19b9fb5fdca779a4ff64eb2d22b5e67a3bb Mon Sep 17 00:00:00 2001 From: "Alexander I. Chebykin" Date: Mon, 27 Jun 2022 09:35:30 +0300 Subject: [PATCH] Minor changes in Windows scripts Minor changes in Windows scripts --- scripts/windowss/send-mail.ps1.template | 20 +++++++++----------- scripts/windowss/send-telegram.ps1.template | 14 +++++++------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/scripts/windowss/send-mail.ps1.template b/scripts/windowss/send-mail.ps1.template index f008606..9720074 100644 --- a/scripts/windowss/send-mail.ps1.template +++ b/scripts/windowss/send-mail.ps1.template @@ -1,11 +1,9 @@ -Function Send-Mail { - $EmailFrom = "yourmailadress@somedomain.com" - $EmailTo = $args[0] - $Subject = $args[1] - $Body = $args[0] - $SMTPServer = "smtp.somedomain.com" - $SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587) - $SMTPClient.EnableSsl = $true - $SMTPClient.Credentials = New-Object System.Net.NetworkCredential("usr", "pass"); - $SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body) -} \ No newline at end of file +$EmailFrom = "yourmailadress@somedomain.com" +$EmailTo = $args[0] +$Subject = $args[1] +$Body = $args[0] +$SMTPServer = "smtp.somedomain.com" +$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587) +$SMTPClient.EnableSsl = $true +$SMTPClient.Credentials = New-Object System.Net.NetworkCredential("usr", "pass"); +$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body) diff --git a/scripts/windowss/send-telegram.ps1.template b/scripts/windowss/send-telegram.ps1.template index caf7d1a..ee72e73 100644 --- a/scripts/windowss/send-telegram.ps1.template +++ b/scripts/windowss/send-telegram.ps1.template @@ -1,10 +1,10 @@ -Function Send-Telegram { - Param([Parameter(Mandatory=$true)][String]$Message) +Param([Parameter(Mandatory=$true)][String]$Message) - $Telegramtoken = "Your_Telegram_Token" - $Telegramchatid = "Your_Telegram_Chat_ID" +$Telegramtoken = "Your_Telegram_Token" +$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)" -} \ No newline at end of file +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + +$Response = Invoke-RestMethod -Uri "https://api.telegram.org/bot$($Telegramtoken)/sendMessage?chat_id=$($Telegramchatid)&text=$($Message)" -- 2.51.0