tacticalrmm/scripts_wip/Win_Blue_Screen_View_And_Em...

35 lines
1.4 KiB
Batchfile
Raw Normal View History

2021-04-27 17:11:30 +00:00
## Update this script for your company, Modify the "mail variables" section
## Also, host BlueScreenView.exe on a website and update the $url variable
## location accordingly
##
## Blue Screen View is available as freeware at
## https://www.nirsoft.net/utils/blue_screen_view.html
###script variables
$scriptName = "Blue Screen View"
$computerName = (get-wmiObject win32_computersystem).name
$computerDomain = (get-wmiObject win32_computersystem).domain
if($computerdomain -notlike '*.*'){ #if there's no period in the domain, (workgroup)
$computerDomain = "$computerDomain.local"
}
###mail variables
$smtpServer = 'mail.server.com'
$smtpPort = '25'
$smtpFrom = "Atera-$computername@$computerdomain"
$smtpTo = 'support@YOURDOMAIN.com'
$messageSubject = "Atera Script: $computerName, $scriptName"
$attachment = "c:\windows\temp\crashes.html"
$messageBody += "----See Attachment----"
###script start
$messageBody = "----Blue Screen View Results----`r`n"
$url = "https://YOURDOMAIN.com/files/BlueScreenView.exe"
$filename = "BlueScreenView.exe"
$client = New-Object System.Net.WebClient
$client.DownloadFile($url, "$env:temp\$filename")
Start-Process -FilePath "$env:temp\$filename" -ArgumentList "/shtml","c:\Windows\temp\crashes.html","/sort 2","/sort ~1"""
###send mail
Send-MailMessage -Port $smtpPort -SmtpServer $smtpServer -From $smtpFrom -To $smtpTo -Subject $messageSubject -Body $messageBody -Attachments $attachment