Update to: Automated Scripting Notifications
mjones
Member Posts: 184 ✭✭✭✭
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
- 41 Getting started
- 25 Read before posting
- 8 Meet and greet
- 237 General
- 64 News and announcements
- 1 Swag
- 1 Roadmap updates
- 79 Resources
- 12 Knowledge Base
- 16 Webinars
- 1 Shared Script Library
- 2 Blog
- 19 Pro Tips
- 27 Got an idea?
- 3 Atera Academy
- 2 ActionAI
- 1 Copilot
- 140 Remote Monitoring and Management
- 84 Remote Monitoring
- 27 Patch Management
- 105 Professional Services Automation
- 64 Helpdesk
- 17 Billing
- 21 Reporting
- 36 Integrations & add-ons
- 20 Integrations
- 10 Add-ons
- 103 Scripting and automations
- 61 Scripts
- 30 Automations