Update to: Automated Scripting Notifications
mjones
Member Posts: 185 ✭✭✭✭
in Automations
Hey All,
I posted a while ago that I was looking for a way to see what scripts were run when a threshold was triggered, and what the results were. I am posting my solution here in hopes that it helps some of you to work around some of the limitations in the reporting.
For example, if a threshold fires for a DNS issue and flushing the cache fixes the problem, the following script would run and then alert you what the results were.
Script:
$txt_File_Output_Path = $Env:windir+"\temp\Atera_"+$Env:ComputerName+"Flush_DNS"+$currDate+".txt"
Start-Transcript -Path $txt_File_Output_Path ipconfig /flushdns
Write-Host "DNS Cache Flushed." Stop-Transcript $smtpServer = "mail.smtp2go.com"
$from = "script@yourdomain.com"
$to = "you@yourdomain.com"
$subject = "Script Output"
$body = "See attached files for script output."
$port = 2525
# Not actually encrypted password, just double Base64 encoded $encrypted = [Text.Encoding]::Utf8.GetString([Convert]::FromBase64String([Text.Encoding]::Utf8.GetString([Convert]::FromBase64String('Double_Base64_String_Goes_Here'))))
$smtpPassword = ConvertTo-SecureString -String $encrypted -AsPlainText -Force $smtpCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $from, $smtpPassword
$attachments = @($txt_File_Output_Path) Send-MailMessage -SmtpServer $smtpServer -From $from -To $to -Subject $subject -Body $body -Attachments $attachments -UseSsl -Port $port -Credential $smtpCredential -Encoding "utf8"
Output would be:
########################### Windows PowerShell transcript start
Start time: 20240409143503
Username: DOMAIN\user
RunAs User: DOMAIN\user
Configuration Name:
Machine: WKS-100 (Microsoft Windows NT 10.0.22621.0)
Host Application: C:\Windows\system32\WindowsPowerShell\v1.0\PowerShell_ISE.exe
Process ID: 36632
PSVersion: 5.1.22621.2506
PSEdition: Desktop
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.22621.2506
BuildVersion: 10.0.22621.2506
CLRVersion: 4.0.30319.42000
WSManStackVersion: 3.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1 ########################### Transcript started, output file is C:\Windows\temp\Atera_WKS-100_Flush_DNS_.txt Windows IP Configuration Successfully flushed the DNS Resolver Cache.
DNS Cache Flushed. ########################### Windows PowerShell transcript end
End time: 20240409143504 ###########################
Previous related posts:
Tagged:
3
Comments
-
Hey @mjones , Sarah from Atera here.
This is exactly what we are looking for from our Community members! Thanks for sharing your insight, hopefully it will help other Atera users moving forward.
1
Topics
- All Topics
- 42 Getting started
- 26 Read before posting
- 8 Meet and greet
- 259 General
- 72 News and announcements
- 2 Swag
- 1 Roadmap updates
- 84 Resources
- 12 Knowledge Base
- 18 Webinars
- 1 Shared Script Library
- 2 Blog
- 21 Pro Tips
- 28 Got an idea?
- 3 Atera Academy
- 2 ActionAI
- 1 Copilot
- 143 Remote Monitoring and Management
- 85 Remote Monitoring
- 28 Patch Management
- 107 Professional Services Automation
- 65 Helpdesk
- 17 Billing
- 22 Reporting
- 41 Integrations & add-ons
- 22 Integrations
- 11 Add-ons
- 108 Scripting and automations
- 62 Scripts
- 32 Automations