Skip to content

Instantly share code, notes, and snippets.

@benyoungnz
Last active November 22, 2021 00:31
Show Gist options
  • Save benyoungnz/32c0503ee49f5744a5d6a2cc98c2de95 to your computer and use it in GitHub Desktop.
Save benyoungnz/32c0503ee49f5744a5d6a2cc98c2de95 to your computer and use it in GitHub Desktop.
AlertTo-VeeamOneReceiver
param([string]$AlarmName,[string]$ObjectName,[string]$Information,[string]$TriggeredOn,[string]$State,[string]$PreviousState,[int]$AlarmId)
<#
.SYNOPSIS
VeeamOneReciever Alert
.DESCRIPTION
Script to send alarms to the VeeamONEReceiver API
.Notes
NAME: AlertTo-VeeamOneReceiver.ps1
LASTEDIT: 23/11/2021
VERSION: 0.1
KEYWORDS: VeeamONE,VeeamONEReceiver,API,VUG
.Link
https://benyoung.blog
#>
#if you are posting from PS 5, youll need this. Otherwise delete and add -SkipCertificateCheck to the IRM.
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
#where your VeeamOneReceiver is located.
$receiverAPI = "https://{yourhost:port}/api/alarm"
#the alarm object, we will convert to JSON for posting
$alarm = [pscustomobject]@{
alarmName = $AlarmName
objectName = $ObjectName
information = $Information
triggeredOn = $TriggeredOn
alarmState = $State
alarmPreviousState = $PreviousState
alarmId = $AlarmId
} | ConvertTo-Json
#fire in the hole!
Invoke-RestMethod -Uri $receiverAPI -Method Post -body $alarm -ContentType "application/json" #-SkipCertificateCheck
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment