Changing from a function to in-line code is something you could have easily done yourself.
$VIPResults = Get-NSVIPAlertingStatus
if ($null -ne $VIPResults) {
foreach ($R in ($VIPResults | Where-Object Status -NotMatch "Up|Out Of Service")) {
if ($R.status -eq "Down") {
$Stauts = $R.Status # "status" is misspelled
$Severity = "5"
}
Elseif ($R.status -eq "Resolved") {
$Stauts = $R.Status # "status" is misspelled
$Severity = "0"
}
Write-Verbose "$(Get-Date): Send Alert: Netscaler $($R.name) on $($R.netscalername) is $($R.Status)" -Verbose
$JSON = @"
{
"summary": "Netscaler $($R.name) on $($R.netscalername) is $($R.Status)",
"node": "$($R.netscalername)",
"team": "",
"severity": $Severity,
"sop_link": "",
"category": "Netscaler component $($R.name)",
"integration": ""
}
"@
Write-Verbose "$(Get-Date):se" -Verbose
# Mail it out
$To = "******@abc.com"
$MailSplat = @{
To = $To
From = "******@no.com"
Subject = "Netscaler $($R.name) on $($R.netscalername) is $($R.Status)"
Body = $JSON
SMTPServer = "hub.com"
BodyAsHtml = $true
}
Send-MailMessage @MailSplat
Invoke-WebRequest -Uri http:\\test.com -Method Post -Body \$Json -ContentType application/json -Verbose
}
}