Update to: Automated Scripting Notifications
mjones
Member Posts: 176 ✭✭✭✭
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
- 40 Getting started
- 24 Read before posting
- 8 Meet and greet
- 219 General
- 59 News and announcements
- Swag
- 1 Roadmap updates
- 68 Resources
- 9 Knowledge Base
- 13 Webinars
- 1 Shared Script Library
- 2 Blog
- 15 Pro Tips
- 26 Got an idea?
- 1 Atera Academy
- 1 ActionAI
- 1 Copilot
- 123 Remote Monitoring and Management
- 77 Remote Monitoring
- 23 Patch Management
- 98 Professional Services Automation
- 61 Helpdesk
- 17 Billing
- 18 Reporting
- 33 Integrations & add-ons
- 19 Integrations
- 10 Add-ons
- 99 Scripting and automations
- 58 Scripts
- 29 Automations