Skip to content

Instantly share code, notes, and snippets.

@ArtisanByteCrafter
Created April 11, 2019 23:04
Show Gist options
  • Save ArtisanByteCrafter/83f06aad5d7503fb0b9f2497fc064d5f to your computer and use it in GitHub Desktop.
Save ArtisanByteCrafter/83f06aad5d7503fb0b9f2497fc064d5f to your computer and use it in GitHub Desktop.
PRTG sensor for Get-WBSummary
param(
[Parameter(Mandatory = $true)]
[string] $Device,
[PSCredential] $Credential
)
$InvokeParams = @{
Computername = $Device
ScriptBlock = { Get-WBSummary }
}
If ($Credential) {
$InvokeParams = @{
Computername = $Device
ScriptBlock = { Get-WBSummary }
Credential = $Credential
}
}
Else {
$InvokeParams = @{
Computername = $Device
ScriptBlock = { Get-WBSummary }
}
}
Try {
$BackupStatus = Invoke-Command @InvokeParams
$result = @"
{
"prtg": {
"result": [
{
"channel": "BackupStatus",
"value": "0"
}
],
"text":"Last successful backup on $($BackupStatus.LastSuccessfulBackupTime)"
}
}
"@
}
Catch {
$Result = @"
{
"prtg": {
"error": "1",
"text": "Query not performed."
}
}
"@
}
$Result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment