broke apprise notification function into its own module to be used by multiple scripts
Security / security (push) Successful in 58s
Security / security (push) Successful in 58s
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
[string] $appriseWebhookURL = $ENV:APPRISEWEBHOOKURL
|
||||
[string] $appriseWebhookTag = $ENV:APPRISEWEBHOOKTAG
|
||||
|
||||
function Send-AppriseNotification
|
||||
{
|
||||
param(
|
||||
# Title of the notification
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]
|
||||
$title,
|
||||
|
||||
# Content of the notification
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]
|
||||
$content
|
||||
)
|
||||
|
||||
$headers = @{
|
||||
"Content-Type"="application/json"
|
||||
}
|
||||
$body = @{
|
||||
title=$title
|
||||
body=$content
|
||||
tags="$appriseWebhookTag"
|
||||
}
|
||||
$json = $body | ConvertTo-Json
|
||||
try {
|
||||
Invoke-WebRequest -URI $appriseWebhookURL -Method post -Body $json -Headers $headers
|
||||
}
|
||||
catch {
|
||||
Write-Host "Notification Error Encountered: $($global:Error[0])"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user