TSNotify Series 6 - Windows Task Scheduler Event ID Based Notifier

Опубликовано: 04 Февраль 2025
на канале: Maharlikans Code
56
5

In this TSNotify Series 6, we will learn how to trigger email notification based on the Windows Task Scheduler Event ID, getting prepared the necessary package dependencies such as Cobra CLI with step by step guide in Golang programming language.

#MaharlikansCode
#TSNotifySeries6
#TaskSchedulerEventIDNotify
#Golang
#LifeAsSoftwareDeveloper
#Maharlikans
#FilipinoSoftwareDeveloper

If you go with extra mile for buying me a cup of coffee, I appreciate it guys: https://ko-fi.com/maharlikanscode

Source Codes:
cmd/encrypt.go:
package cmd

import (
"fmt"
"tsnotify/config"

"github.com/itrepablik/itrlog"
"github.com/itrepablik/tago"
"github.com/spf13/cobra"
)

var encryptCmd = &cobra.Command{
Use: "encrypt",
Short: "To encrypt any classified text",
Long: `This is to encrypt any classified text or message to hide the real message.`,
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
origMsg := args[0]
fmt.Println("origMsg: ", origMsg)

// To encrypt the classified text
encText, err := tago.Encrypt(origMsg, config.MyEncryptDecryptSK)
if err != nil {
itrlog.Fatalw("error encrypting your classified text: ", err)
}
fmt.Println("encrypted text:", encText)
itrlog.Info("encrypted text:", encText)
},
}

func init() {
rootCmd.AddCommand(encryptCmd)
}
config.yaml:
app:
name: tsnotify
version: 1.0.0

smtp:
host: smtp.gmail.com
port: 465
username: khpapCM=
password: iRJCuByymhGj3FcG
enabled: false

sendgrid:
apikey:
enabled: true

logging:
datetimeformat: "02 Jan 2006 03:04:05 PM"
enabled: true

datetimeformat: "Jan 02 2006 03:04:05 PM"
enabled: false

default:
from: [email protected]
subject: Task scheduler status alert
status: [Fail, Warning, Disabled]

monitored_tasks:
taskname: Gokopy CopyMD
recipients: [[email protected], [email protected]]

taskname: NitroSense
recipients: [[email protected]]

monitored_events:
eventid: 102
recipients: [[email protected], [email protected]]

eventid: 104 # Logon failure
recipients: [[email protected], [email protected]]

eventid: 325 # Queued
recipients: [[email protected], [email protected]]