Merge pull request #466 from InsaneTechnologies/develop

Add in Client and Site variables
This commit is contained in:
Dan 2021-05-03 23:49:35 -07:00 committed by GitHub
commit 33bfc8cfe8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 65 additions and 2 deletions

View File

@ -9,7 +9,9 @@ Also accepts uninstall variable to remove the installed instance if required.
param ( param (
[string] $serviceName, [string] $serviceName,
[string] $url, [string] $url,
[string] $action [string] $action,
[string] $company,
[string] $site
) )
$ErrorCount = 0 $ErrorCount = 0
@ -82,7 +84,7 @@ if ($action -eq "uninstall") {
{ {
$start_time = Get-Date $start_time = Get-Date
$wc = New-Object System.Net.WebClient $wc = New-Object System.Net.WebClient
$wc.DownloadFile("$url", "$OutPath\$output") $wc.DownloadFile("$url&c=$company&c=$site", "$OutPath\$output")
Start-Process -FilePath $OutPath\$output -Wait Start-Process -FilePath $OutPath\$output -Wait
Write-Output "Time taken to download and install: $((Get-Date).Subtract($start_time).Seconds) second(s)" Write-Output "Time taken to download and install: $((Get-Date).Subtract($start_time).Seconds) second(s)"
exit 0 exit 0

View File

@ -0,0 +1,61 @@
<#
Microsoft Teams notifications
Submitted by Insane Technologies / David Rudduck
requires
- agent {{agent.hostname}}
- client {{client.name}}
- site {{site.name}}
- user {{agent.logged_in_user}}
- reboot {{agent.needs_reboot}}
- patches {{agent.patches_last_installed}}
- alert_time {{alert.alert_time}}
- message {{alert.message}}
- severity {{alert.severity}}
#>
param (
[string] $agent,
[string] $client,
[string] $site,
[string] $user,
[string] $reboot,
[string] $patches,
[string] $time,
[string] $message,
[string] $severity
)
$webhookurl = 'ADDYOURMSTEAMSWEBHOOKURLHERE'
if($severity -eq "error"){
$colour = 'ff0000'
}
if($severity -eq "warning"){
$color = 'ffa500'
}
if($severity -eq "info"){
$colour = 'ffff00'
}
$msteams_payload = '{"@context": "https://schema.org/extensions", "@type": "MessageCard", "summary": "TacticalRMM Alert", "themeColor": "' + $colour +'", '
$msteams_payload = $msteams_payload + '"text": "'
if($time) {
$msteams_payload = $msteams_payload + '<b>Alert Time:</b> ' + $time +'<br>'
}
$msteams_payload = $msteams_payload + '<b>Client:</b> ' + $client +'<br>'
$msteams_payload = $msteams_payload + '<b>Site:</b> ' + $site +'<br>'
$msteams_payload = $msteams_payload + '<b>Device:</b> ' + $agent +'<br>'
if($user) {
$msteams_payload = $msteams_payload + '<b>User:</b> ' + $user +'<br>'
}
if($reboot) {
$msteams_payload = $msteams_payload + '<b>Device has pending reboot</b><br>'
}
if($patches) {
$msteams_payload = $msteams_payload + '<b>Patches were last applied:</b> ' + $patches +'<br>'
}
$msteams_payload = $msteams_payload + $message + '"}'
# Write-Output $msteams_payload
Invoke-RestMethod -Method post -ContentType 'Application/Json' -Body $msteams_payload -Uri $webhookurl